diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0837041f..fd41c586 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-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork @@ -36,8 +36,33 @@ jobs: - name: Run lints run: ./scripts/lint + + build: + timeout-minutes: 15 + name: build + runs-on: ${{ github.repository == 'stainless-sdks/orb-java' && '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: 10 + timeout-minutes: 15 name: test runs-on: ${{ github.repository == 'stainless-sdks/orb-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 9875f43e..eab3bf49 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 @@ -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 4e81838d..b1346e6d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,6 @@ .gradle .idea .kotlin -build +build/ codegen.log kls_database.db diff --git a/.release-please-manifest.json b/.release-please-manifest.json index c3c95522..eb4e0dba 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.9.0" + ".": "1.10.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index c03739d1..3407ffd1 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 +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/CHANGELOG.md b/CHANGELOG.md index a326cfbd..ec0b9223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,56 @@ # Changelog +## 1.10.0 (2025-10-07) + +Full Changelog: [v1.9.0...v1.10.0](https://github.com/orbcorp/orb-java/compare/v1.9.0...v1.10.0) + +### ⚠ BREAKING CHANGES + +* **api:** define shared model ConversionRateConfig + +### Features + +* add retryable exception ([cf6742e](https://github.com/orbcorp/orb-java/commit/cf6742e0ace7ef26c53fdf1c6ead9f742a326094)) +* **api:** api update ([ab79480](https://github.com/orbcorp/orb-java/commit/ab794808febc46a53d5baf1e41f0ad7b1ab8d1df)) +* **api:** api update ([0f4e585](https://github.com/orbcorp/orb-java/commit/0f4e5853aab9546952e9d80b4c2e50688a8caf6d)) +* **api:** api update ([617892e](https://github.com/orbcorp/orb-java/commit/617892e6526e1717415bfa630529ffce50a70b96)) +* **api:** api update ([bf412bc](https://github.com/orbcorp/orb-java/commit/bf412bca3a157a0e41fef19a5d915c095b09eda1)) +* **api:** api update ([6aa1d53](https://github.com/orbcorp/orb-java/commit/6aa1d5370247b08c937ca7faa9fcacf5b21ed081)) +* **api:** api update ([321aa41](https://github.com/orbcorp/orb-java/commit/321aa4197ce9dbc8601ec7578d0f70017e37c2f6)) +* **api:** api update ([cf6fd19](https://github.com/orbcorp/orb-java/commit/cf6fd1990dc2781ebc0ab860b135ce4b90a58fa2)) +* **api:** api update ([9c8977c](https://github.com/orbcorp/orb-java/commit/9c8977c14697c4907f13e29189a62c2aea441924)) +* **api:** api update ([247937e](https://github.com/orbcorp/orb-java/commit/247937ebe3dba64b53c180a9a58460e10cde4a8c)) +* **api:** api update ([5d00bf2](https://github.com/orbcorp/orb-java/commit/5d00bf2a8be3610043bbd620eb724d13788fc89a)) +* **api:** api update ([05b6a4e](https://github.com/orbcorp/orb-java/commit/05b6a4e2d2e551b8b09168d2a8d6e34851fcd784)) +* **api:** api update ([3b2489b](https://github.com/orbcorp/orb-java/commit/3b2489bdb730033a389ec76cc824df8eb351c678)) +* **api:** api update ([e90f837](https://github.com/orbcorp/orb-java/commit/e90f837c716a2fe6955df54c844b4320a1a26d8b)) +* **api:** define shared model ConversionRateConfig ([13fc2ef](https://github.com/orbcorp/orb-java/commit/13fc2efb464953fc534dbd09ed34b003c17a3d0d)) +* **client:** ensure compat with proguard ([83ddd55](https://github.com/orbcorp/orb-java/commit/83ddd55a2e265b3f2426f47868bc5a596509e3a8)) +* **client:** expose sleeper option ([427df35](https://github.com/orbcorp/orb-java/commit/427df355df00bafcdb972fbfb758f7cb0646aab6)) +* extract minimum composite to type ([3e25650](https://github.com/orbcorp/orb-java/commit/3e256505b03e771aef66c8a435f27a6ec3b9e237)) + + +### Bug Fixes + +* **ci:** use java-version 21 for publish step ([b290b3a](https://github.com/orbcorp/orb-java/commit/b290b3a558d6f1b4419975855a22c0f0b8b055e2)) +* **client:** deserialization of empty objects ([1764089](https://github.com/orbcorp/orb-java/commit/1764089476594bd942efe77f15d4744e6c0a01dd)) +* **client:** ensure single timer is created per client ([427df35](https://github.com/orbcorp/orb-java/commit/427df355df00bafcdb972fbfb758f7cb0646aab6)) +* **client:** incorrect `getPackageVersion` impl ([9bc6ac9](https://github.com/orbcorp/orb-java/commit/9bc6ac99cc3a432ddc30f43dda41d076f4197883)) +* **client:** r8 support ([27da721](https://github.com/orbcorp/orb-java/commit/27da7219bb085292eba8cf247a8574689f922300)) + + +### Chores + +* fix formatting ([a6e527f](https://github.com/orbcorp/orb-java/commit/a6e527f946e40ebbfebc97c4eaeec1900845197a)) +* improve formatter performance ([5d37bc1](https://github.com/orbcorp/orb-java/commit/5d37bc171ae17fbfb70c63743afde6b04e29ff1c)) +* **internal:** bump ci test timeout ([0e68dd4](https://github.com/orbcorp/orb-java/commit/0e68dd443b79c48810c94749f88cfc2d9286a725)) +* **internal:** change some comment formatting ([7e80bfe](https://github.com/orbcorp/orb-java/commit/7e80bfeb93b40dc060dd5947e8e37d4fb68a4955)) +* **internal:** codegen related update ([97bd293](https://github.com/orbcorp/orb-java/commit/97bd293da263a5259bac93d2f9d9aeb0f10d5c65)) +* **internal:** codegen related update ([3a4300a](https://github.com/orbcorp/orb-java/commit/3a4300ae19b4ad4c9f82056658d88013a35c992e)) +* **internal:** codegen related update ([185acb8](https://github.com/orbcorp/orb-java/commit/185acb801fe845d8b33f741e1e1f1e07550fd92f)) +* **internal:** codegen related update ([76d269d](https://github.com/orbcorp/orb-java/commit/76d269d0cba09f1150af878d603292b92e003241)) +* **internal:** reduce proguard ci logging ([9b4d208](https://github.com/orbcorp/orb-java/commit/9b4d20849c0af2b5945f155aad5a91c338020f56)) + ## 1.9.0 (2025-07-26) Full Changelog: [v1.8.0...v1.9.0](https://github.com/orbcorp/orb-java/compare/v1.8.0...v1.9.0) diff --git a/README.md b/README.md index b0b339ee..195b519a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.9.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.10.0) @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho ### Gradle ```kotlin -implementation("com.withorb.api:orb-java:1.9.0") +implementation("com.withorb.api:orb-java:1.10.0") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:1.9.0") com.withorb.api orb-java - 1.9.0 + 1.10.0 ``` @@ -231,6 +231,8 @@ The SDK throws custom unchecked exception types: - [`OrbIoException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbIoException.kt): I/O networking errors. +- [`OrbRetryableException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt): Generic error indicating a failure that could be retried by the client. + - [`OrbInvalidDataException`](orb-java-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-java-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. @@ -361,6 +363,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-java-core` is published with a [configuration file](orb-java-core/src/main/resources/META-INF/proguard/orb-java-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/build.gradle.kts b/build.gradle.kts index 961c7eab..8e1585b2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,16 @@ allprojects { group = "com.withorb.api" - version = "1.9.0" // x-release-please-version + version = "1.10.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 778c89de..c6dc92ec 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 dfbacb86..70fc33f4 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 2d4a5c55..b908b3be 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 ff76593f..6680f9ce 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-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt index 931e530c..a3fd603e 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt +++ b/orb-java-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.AsyncStreamResponse import com.withorb.api.core.http.Headers @@ -126,11 +127,24 @@ class OrbOkHttpClient private constructor() { * The executor to use for running [AsyncStreamResponse.Handler] callbacks. * * Defaults to a dedicated cached thread pool. + * + * This class takes ownership of the executor and shuts it down, if possible, when closed. */ fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { clientOptions.streamHandlerExecutor(streamHandlerExecutor) } + /** + * 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-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt index 7c2423c7..88bdd9fe 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt +++ b/orb-java-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.AsyncStreamResponse import com.withorb.api.core.http.Headers @@ -126,11 +127,24 @@ class OrbOkHttpClientAsync private constructor() { * The executor to use for running [AsyncStreamResponse.Handler] callbacks. * * Defaults to a dedicated cached thread pool. + * + * This class takes ownership of the executor and shuts it down, if possible, when closed. */ fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { clientOptions.streamHandlerExecutor(streamHandlerExecutor) } + /** + * 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-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt index fa0e22b0..4023c67f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt @@ -153,7 +153,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-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt index e3671e40..d086412a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt @@ -146,7 +146,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-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt index b2464f27..cd66b87c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt @@ -13,6 +13,7 @@ import java.time.Clock import java.time.Duration import java.util.Optional import java.util.concurrent.Executor +import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.ThreadFactory import java.util.concurrent.atomic.AtomicLong @@ -26,6 +27,8 @@ private constructor( * The HTTP client to use in the SDK. * * Use the one published in `orb-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. */ @get:JvmName("httpClient") val httpClient: HttpClient, /** @@ -47,8 +50,20 @@ private constructor( * The executor to use for running [AsyncStreamResponse.Handler] callbacks. * * Defaults to a dedicated cached thread pool. + * + * This class takes ownership of the executor and shuts it down, if possible, when closed. */ @get:JvmName("streamHandlerExecutor") val streamHandlerExecutor: Executor, + /** + * 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. + */ + @get:JvmName("sleeper") val sleeper: Sleeper, /** * The clock to use for operations that require timing, like retries. * @@ -143,6 +158,7 @@ private constructor( private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() private var streamHandlerExecutor: Executor? = null + private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() @@ -159,6 +175,7 @@ private constructor( checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper streamHandlerExecutor = clientOptions.streamHandlerExecutor + sleeper = clientOptions.sleeper clock = clientOptions.clock baseUrl = clientOptions.baseUrl headers = clientOptions.headers.toBuilder() @@ -174,6 +191,8 @@ private constructor( * The HTTP client to use in the SDK. * * Use the one published in `orb-java-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) @@ -202,11 +221,27 @@ private constructor( * The executor to use for running [AsyncStreamResponse.Handler] callbacks. * * Defaults to a dedicated cached thread pool. + * + * This class takes ownership of the executor and shuts it down, if possible, when closed. */ fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { - this.streamHandlerExecutor = streamHandlerExecutor + this.streamHandlerExecutor = + if (streamHandlerExecutor is ExecutorService) + PhantomReachableExecutorService(streamHandlerExecutor) + else streamHandlerExecutor } + /** + * 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. * @@ -398,6 +433,25 @@ private constructor( */ fun build(): ClientOptions { val httpClient = checkRequired("httpClient", httpClient) + val streamHandlerExecutor = + streamHandlerExecutor + ?: PhantomReachableExecutorService( + Executors.newCachedThreadPool( + object : ThreadFactory { + + private val threadFactory: ThreadFactory = + Executors.defaultThreadFactory() + private val count = AtomicLong(0) + + override fun newThread(runnable: Runnable): Thread = + threadFactory.newThread(runnable).also { + it.name = + "orb-stream-handler-thread-${count.getAndIncrement()}" + } + } + ) + ) + val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper()) val apiKey = checkRequired("apiKey", apiKey) val headers = Headers.builder() @@ -421,26 +475,15 @@ private constructor( httpClient, RetryingHttpClient.builder() .httpClient(httpClient) + .sleeper(sleeper) .clock(clock) .maxRetries(maxRetries) .idempotencyHeader("Idempotency-Key") .build(), checkJacksonVersionCompatibility, jsonMapper, - streamHandlerExecutor - ?: Executors.newCachedThreadPool( - object : ThreadFactory { - - private val threadFactory: ThreadFactory = - Executors.defaultThreadFactory() - private val count = AtomicLong(0) - - override fun newThread(runnable: Runnable): Thread = - threadFactory.newThread(runnable).also { - it.name = "orb-stream-handler-thread-${count.getAndIncrement()}" - } - } - ), + streamHandlerExecutor, + sleeper, clock, baseUrl, headers.build(), @@ -453,4 +496,20 @@ 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() + (streamHandlerExecutor as? ExecutorService)?.shutdown() + sleeper.close() + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/DefaultSleeper.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/DefaultSleeper.kt new file mode 100644 index 00000000..f80d7686 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/DefaultSleeper.kt @@ -0,0 +1,28 @@ +package com.withorb.api.core + +import java.time.Duration +import java.util.Timer +import java.util.TimerTask +import java.util.concurrent.CompletableFuture + +class DefaultSleeper : Sleeper { + + private val timer = Timer("DefaultSleeper", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + + override fun close() = timer.cancel() +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/PhantomReachableExecutorService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/PhantomReachableExecutorService.kt new file mode 100644 index 00000000..b4617be2 --- /dev/null +++ b/orb-java-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-java-core/src/main/kotlin/com/withorb/api/core/PhantomReachableSleeper.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/PhantomReachableSleeper.kt new file mode 100644 index 00000000..32a73ac1 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/PhantomReachableSleeper.kt @@ -0,0 +1,23 @@ +package com.withorb.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * 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 fun sleepAsync(duration: Duration): CompletableFuture = + sleeper.sleepAsync(duration) + + override fun close() = sleeper.close() +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt index 9045e4db..f0f63ba4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt +++ b/orb-java-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") diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Sleeper.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Sleeper.kt new file mode 100644 index 00000000..a10a12ea --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Sleeper.kt @@ -0,0 +1,21 @@ +package com.withorb.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * 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]. */ + fun sleepAsync(duration: Duration): CompletableFuture + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Timeout.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Timeout.kt index 182de0a9..0da3dbe9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Timeout.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Timeout.kt @@ -157,10 +157,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-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt index e0ad480d..c392401d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt @@ -6,6 +6,8 @@ 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.CompletableFuture +import java.util.concurrent.locks.Lock @JvmSynthetic internal fun T?.getOrThrow(name: String): T = @@ -95,3 +97,24 @@ internal fun Headers.getRequiredHeader(name: String): String = values(name).firstOrNull() ?: throw OrbInvalidDataException("Could not find $name header") internal interface Enum + +/** + * Executes the given [action] while holding the lock, returning a [CompletableFuture] with the + * result. + * + * @param action The asynchronous action to execute while holding the lock + * @return A [CompletableFuture] that completes with the result of the action + */ +@JvmSynthetic +internal fun Lock.withLockAsync(action: () -> CompletableFuture): CompletableFuture { + lock() + val future = + try { + action() + } catch (e: Throwable) { + unlock() + throw e + } + future.whenComplete { _, _ -> unlock() } + return future +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt index cba6f15b..e53177d2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt @@ -1,8 +1,11 @@ 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 import java.io.IOException import java.time.Clock import java.time.Duration @@ -10,8 +13,6 @@ import java.time.OffsetDateTime import java.time.format.DateTimeFormatter import java.time.format.DateTimeParseException import java.time.temporal.ChronoUnit -import java.util.Timer -import java.util.TimerTask import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.ThreadLocalRandom @@ -129,7 +130,10 @@ private constructor( return executeWithRetries(modifiedRequest, requestOptions) } - 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 @@ -176,9 +180,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: @@ -233,33 +238,14 @@ private constructor( class Builder internal constructor() { private var httpClient: HttpClient? = null - private var sleeper: Sleeper = - object : Sleeper { - - private val timer = Timer("RetryingHttpClient", true) - - override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) - - override fun sleepAsync(duration: Duration): CompletableFuture { - val future = CompletableFuture() - timer.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - duration.toMillis(), - ) - return future - } - } + 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 } - @JvmSynthetic 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 } @@ -270,17 +256,10 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( checkRequired("httpClient", httpClient), - sleeper, + sleeper ?: DefaultSleeper(), clock, maxRetries, idempotencyHeader, ) } - - internal interface Sleeper { - - fun sleep(duration: Duration) - - fun sleepAsync(duration: Duration): CompletableFuture - } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt new file mode 100644 index 00000000..61061c4e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbRetryableException.kt @@ -0,0 +1,14 @@ +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 +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : OrbException(message, cause) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt index 9b5fa1d3..bfbf6c22 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt +++ b/orb-java-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, @@ -205,12 +206,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-java-core/src/main/kotlin/com/withorb/api/models/Address.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Address.kt index 9ddf4805..de9c14ae 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Address.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Address.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Address +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val city: JsonField, private val country: JsonField, @@ -340,12 +341,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-java-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt index 25b700c0..9dbc4e7f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt @@ -17,6 +17,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AddressInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val city: JsonField, private val country: JsonField, @@ -315,12 +316,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-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt index 7fe9f69e..17115a57 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt @@ -31,6 +31,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AdjustmentInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustment: JsonField, @@ -512,10 +513,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 { @@ -655,12 +662,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-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt index ab3de315..28826e15 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AffectedBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val expiryDate: JsonField, @@ -247,12 +248,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-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt index 06198fab..132a3db8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt @@ -20,6 +20,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class AggregatedCost +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val perPriceCosts: JsonField>, private val subtotal: JsonField, @@ -330,12 +331,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-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt index 3d7bc937..f35084b4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt @@ -28,6 +28,7 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -616,6 +617,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, @@ -754,12 +756,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 @@ -768,6 +770,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, @@ -1043,12 +1046,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 @@ -1191,7 +1199,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() @@ -1201,6 +1209,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, @@ -1393,12 +1402,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 @@ -1411,12 +1423,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-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt index 01c06640..23046502 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt @@ -340,6 +340,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, @@ -581,12 +582,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 @@ -717,7 +722,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() @@ -730,10 +735,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-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt index 6852ecd0..e3332964 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt @@ -349,6 +349,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, @@ -590,12 +591,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 @@ -726,7 +731,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() @@ -739,10 +744,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-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt index 0f3748d6..7329b98c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt @@ -348,6 +348,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, @@ -587,12 +588,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 @@ -717,7 +722,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() @@ -730,10 +735,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-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt index 5ad3565f..009f1233 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt @@ -244,10 +244,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-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt index d7dc775f..65cfb8a8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt @@ -244,10 +244,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-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt index 04cab053..c1a378da 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt index aee23ad7..579d4353 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt @@ -134,10 +134,14 @@ private constructor( return true } - return /* spotless:off */ other is AlertListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is AlertListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "AlertListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt index 76540e99..bfa4b279 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class AlertListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -217,12 +218,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-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt index 9e9689ef..a95f34f5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt @@ -16,7 +16,7 @@ import kotlin.jvm.optionals.getOrNull * * 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 @@ -329,10 +329,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-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt index 23daf4dd..293640ff 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt @@ -176,10 +176,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-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt index 6a2e123e..96f3f152 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt @@ -279,6 +279,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, @@ -443,12 +444,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 @@ -461,10 +462,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-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt index 440e9c08..0b36b3c5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Allocation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allowsRollover: JsonField, private val currency: JsonField, @@ -244,12 +245,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-java-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt index 2c0f3e57..9e161e9e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AmendmentLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -742,7 +743,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() @@ -862,7 +863,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() @@ -964,12 +965,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 @@ -981,12 +980,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-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt index b88a2c7f..9473def7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AmountDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountDiscount: JsonField, private val discountType: JsonField, @@ -470,7 +471,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() @@ -483,12 +484,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-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt index 630e5848..e37fa4d7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt @@ -22,6 +22,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AmountDiscountInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountDiscount: JsonField, private val appliesToPriceIntervalIds: JsonField>, @@ -523,7 +524,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() @@ -536,12 +537,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-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 83ba798e..a901b084 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-java-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 @@ -32,12 +33,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** - * 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?, @@ -581,6 +577,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>, @@ -1144,12 +1141,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 @@ -1158,6 +1174,7 @@ private constructor( } class AddAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val planPhaseOrder: JsonField, @@ -1583,10 +1600,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 { @@ -1715,12 +1738,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 @@ -1729,6 +1755,7 @@ private constructor( } class AddPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val planPhaseOrder: JsonField, @@ -1765,7 +1792,7 @@ private constructor( fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("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). @@ -1878,7 +1905,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)) /** Alias for calling [Builder.price] with `price.orElse(null)`. */ @@ -1896,27 +1923,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.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)) + /** 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)`. */ @@ -1931,9 +1949,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 @@ -1942,10 +1967,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)`. */ @@ -1956,6 +1991,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)`. @@ -1970,6 +2009,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)`. @@ -1977,10 +2023,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)`. */ @@ -2016,22 +2058,14 @@ 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.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** 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() @@ -2099,31 +2133,32 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.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 tieredBps: NewPlanTieredBpsPrice? = null, - private val bps: NewPlanBpsPrice? = null, - private val bulkBps: NewPlanBulkBpsPrice? = 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? = @@ -2132,27 +2167,21 @@ 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 percent: Percent? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) @@ -2163,13 +2192,22 @@ private constructor( fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) fun packageWithAllocation(): Optional = Optional.ofNullable(packageWithAllocation) - fun tieredWithProration(): Optional = + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) fun unitWithProration(): Optional = @@ -2178,18 +2216,21 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) - fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) @@ -2207,30 +2248,21 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + fun percent(): Optional = Optional.ofNullable(percent) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != null + fun isMatrix(): Boolean = matrix != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -2238,23 +2270,31 @@ private constructor( 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 - 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 @@ -2267,27 +2307,21 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isPercent(): Boolean = percent != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isEventOutput(): Boolean = eventOutput != 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 asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") - fun asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -2298,13 +2332,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 = @@ -2313,18 +2356,21 @@ private constructor( 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 asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") @@ -2340,45 +2386,46 @@ private constructor( fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asPercent(): Percent = percent.getOrThrow("percent") - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): Optional = Optional.ofNullable(_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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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 -> 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 -> @@ -2391,11 +2438,9 @@ 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) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -2412,32 +2457,20 @@ 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() } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() } - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() } override fun visitThresholdTotalAmount( @@ -2456,10 +2489,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( @@ -2468,8 +2505,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() } @@ -2486,6 +2535,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) { @@ -2498,16 +2553,16 @@ private constructor( groupedWithMeteredMinimum.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) { - matrixWithDisplayName.validate() + groupedWithMinMaxThresholds.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) { - bulkWithProration.validate() + matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( @@ -2541,20 +2596,16 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + override fun visitPercent(percent: Percent) { + percent.validate() } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() } } ) @@ -2581,21 +2632,14 @@ 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 visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewPlanBpsPrice) = bps.validity() + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() override fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice @@ -2608,16 +2652,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( @@ -2628,6 +2683,10 @@ private constructor( groupedAllocation: NewPlanGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -2636,14 +2695,14 @@ private constructor( 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() @@ -2665,16 +2724,13 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + override fun visitPercent(percent: Percent) = percent.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2685,38 +2741,102 @@ 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 && + 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 = /* 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, + 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}" - 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}" + 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 -> "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 -> @@ -2727,11 +2847,9 @@ 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}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -2740,20 +2858,13 @@ private constructor( @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - @JvmStatic - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = Price(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: NewPlanBpsPrice) = Price(bps = bps) + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) - @JvmStatic fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = Price(bulkBps = bulkBps) + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = @@ -2768,8 +2879,13 @@ private constructor( Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic fun ofPackageWithAllocation( @@ -2777,7 +2893,15 @@ private constructor( ) = Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = Price(tieredWithProration = tieredWithProration) @JvmStatic @@ -2788,6 +2912,10 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice @@ -2798,15 +2926,16 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JvmStatic fun ofMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - @JvmStatic fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = Price(groupedTieredPackage = groupedTieredPackage) @@ -2832,17 +2961,12 @@ private constructor( ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -2852,19 +2976,13 @@ private constructor( fun visitUnit(unit: NewPlanUnitPrice): T - fun visitPackage(package_: NewPlanPackagePrice): T - - fun visitMatrix(matrix: NewPlanMatrixPrice): T - fun visitTiered(tiered: NewPlanTieredPrice): T - fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T - - fun visitBps(bps: NewPlanBpsPrice): T + fun visitBulk(bulk: NewPlanBulkPrice): T - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T + fun visitPackage(package_: NewPlanPackagePrice): T - fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitMatrix(matrix: NewPlanMatrixPrice): T fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice @@ -2874,18 +2992,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 @@ -2894,12 +3024,14 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ): T @@ -2920,15 +3052,11 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun visitPercent(percent: Percent): T - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitEventOutput(eventOutput: EventOutput): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -2958,38 +3086,25 @@ 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) } ?: 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) } + "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, @@ -3011,12 +3126,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" -> { @@ -3027,11 +3147,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) } @@ -3051,6 +3184,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, @@ -3067,20 +3208,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" -> { @@ -3123,26 +3264,22 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { + "minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) } } @@ -3159,36 +3296,40 @@ 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.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.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 -> 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 -> @@ -3199,2621 +3340,16631 @@ 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.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 equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddPrice && allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties /* spotless:on */ - } + 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(), + ) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } - /* spotless:on */ + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an 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 + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected 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}" - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - 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()) + /** + * 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 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 billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_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(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * 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 + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * 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 per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, 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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - fun toBuilder() = Builder().from(this) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - companion object { + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - private var adjustmentId: 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @JvmSynthetic - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(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(): Optional = referenceId.getOptional("reference_id") - /** - * 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 [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** 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 - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * 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 - /** - * 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: - * ```java - * .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() + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw 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: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + 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 + @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, + ) { + + @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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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( + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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(): Optional = planPhaseOrder.getOptional("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: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (adjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + 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(): Optional = planPhaseOrder.getOptional("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: + * ```java + * .priceId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + 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(): Optional = planPhaseOrder.getOptional("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: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * 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?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + /** 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(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic 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().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + 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(): Optional = + allocationPrice.getOptional("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(): Optional = planPhaseOrder.getOptional("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(): Optional = price.getOptional("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: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * 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?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * 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: + * ```java + * .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().ifPresent { it.validate() } planPhaseOrder() + price().ifPresent { it.validate() } 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.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(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + 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().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + 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) + } } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (adjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + internal class Serializer : BaseSerializer(Price::class) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + 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") + } + } } - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ - } + 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun hashCode(): Int = hashCode + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("conversion_rate") - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - class RemovePrice - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: 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(): Optional = currency.getOptional("currency") - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, 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(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * 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") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_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(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * 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 + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * 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 + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - 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 [RemovePrice]. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - */ - @JvmStatic 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 [RemovePrice]. */ - class Builder internal constructor() { + /** + * 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 - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmSynthetic - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.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 - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * 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.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Returns the raw JSON value of [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 phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * 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.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 [externalPriceId]. + * + * 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 [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + @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 toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** 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() + + @JvmSynthetic + 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() + } - priceId() - planPhaseOrder() - validated = true - } + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 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. + */ + 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (priceId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return /* spotless:off */ other is RemovePrice && priceId == other.priceId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(priceId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 hashCode(): Int = hashCode + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @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()) + /** + * Within each billing cycle, specifies the 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. - * - * @throws OrbInvalidDataException if 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 [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 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 additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * 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(): Optional = planPhaseOrder.getOptional("plan_phase_order") + 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) + } - /** - * 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 removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private var validated: Boolean = false - fun toBuilder() = Builder().from(this) + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - companion object { + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.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, + } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(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 + } - /** - * 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 an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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() - ) + private var validated: Boolean = false - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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() - ) + known() + validated = true + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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 a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + return other is Cadence && value == other.value + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + override fun hashCode() = value.hashCode() - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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 toString() = value.toString() + } - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * 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 - } + @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) + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + @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: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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() } + } - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * 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) + } + } - /** - * 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 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .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(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + tiers().forEach { it.validate() } + validated = true + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.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) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + @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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** 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, - ) { + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + private var validated: Boolean = false - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + fun validate(): Tier = apply { + if (validated) { + return@apply + } - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + tierLowerBound() + unitAmount() + validated = true + } - fun minimum(): Optional = Optional.ofNullable(minimum) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun maximum(): Optional = Optional.ofNullable(maximum) + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + override fun hashCode(): Int = hashCode - fun isUsageDiscount(): Boolean = usageDiscount != null + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - fun isAmountDiscount(): Boolean = amountDiscount != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMinimum(): Boolean = minimum != null + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun isMaximum(): Boolean = maximum != null + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + override fun hashCode(): Int = hashCode - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, 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(): Optional = Optional.ofNullable(_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]. */ + @JvmStatic 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() + @JvmSynthetic + 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) + } - 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 [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. - */ - @JvmSynthetic - 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. + */ + @JvmSynthetic + 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 + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + 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 + } - 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, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } - companion object { + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + 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}" + } - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + 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, + ) { + + @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(), + ) - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * 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" + ) - @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): 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(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): 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(): Optional = + conversionRate.getOptional("conversion_rate") - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): 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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun visitMinimum(minimum: NewMinimum): 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(): Optional = currency.getOptional("currency") - fun visitMaximum(maximum: NewMaximum): 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(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. + * An alias for the price. * - * 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 externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. * - * @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 fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - 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) - } - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - return Adjustment(_json = json) - } - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - internal class Serializer : BaseSerializer(Adjustment::class) { + /** + * Returns the raw JSON value 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 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 [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 - 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 /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + /** + * Returns the raw JSON value of [billableMetricId]. + * + * 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(): Int = 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() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$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 - class ReplacePrice - 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 [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("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 [conversionRateConfig]. + * + * 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 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * 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(): Optional = - allocationPrice.getOptional("allocation_price") + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * 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 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(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * 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 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(): Optional = price.getOptional("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 - /** - * 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 [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * 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 [invoicingCycleConfiguration]. + * + * 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 [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 [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 [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 [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) - } + @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) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** 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() + + @JvmSynthetic + 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() + } - companion object { + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic 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 [ReplacePrice]. */ - class Builder internal constructor() { + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 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() + /** + * If the Price represents a fixed cost, the price 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * 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 - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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.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 - } + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Within each billing cycle, specifies the 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 [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * 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 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) + } - /** Alias for calling [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(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 removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewPlanTieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewPlanBpsPrice) = price(Price.ofBps(bps)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewPlanBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> 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.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + private var validated: Boolean = false - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + known() + validated = true + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + return other is Cadence && value == other.value + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + override fun hashCode() = value.hashCode() - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + override fun toString() = value.toString() + } - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** 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 [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + @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) + } - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + @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: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** 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() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** 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 + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** 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 + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** 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 + } - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** 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 + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .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 - private var validated: Boolean = false + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - planPhaseOrder() - price().ifPresent { it.validate() } - 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + 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. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } - /** 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, - ) { + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } - fun unit(): Optional = Optional.ofNullable(unit) + override fun hashCode(): Int = hashCode - fun package_(): Optional = Optional.ofNullable(package_) + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } - fun matrix(): Optional = Optional.ofNullable(matrix) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire 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 tiered(): Optional = Optional.ofNullable(tiered) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) + fun toBuilder() = Builder().from(this) - fun bps(): Optional = Optional.ofNullable(bps) + companion object { - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun bulk(): Optional = Optional.ofNullable(bulk) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + private var additionalProperties: MutableMap = + mutableMapOf() - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun groupedWithProratedMinimum(): Optional = - Optional.ofNullable(groupedWithProratedMinimum) + private var validated: Boolean = false - fun groupedWithMeteredMinimum(): Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + validated = true + } - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + override fun hashCode(): Int = hashCode - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + 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 isUnit(): Boolean = unit != null + 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 isPackage(): Boolean = package_ != null + override fun hashCode(): Int = hashCode - fun isMatrix(): Boolean = matrix != 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 isTiered(): Boolean = tiered != null + 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(), + ) - fun isTieredBps(): Boolean = tieredBps != 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 isBps(): Boolean = bps != 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 isBulkBps(): Boolean = bulkBps != null + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 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 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") - 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(): Optional = + billableMetricId.getOptional("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(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != 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(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun isBulkWithProration(): Boolean = bulkWithProration != 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(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != 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(): Optional = metadata.getOptional("metadata") - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != 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(): Optional = referenceId.getOptional("reference_id") - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != 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 + + /** + * Returns the raw JSON value of [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 - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * 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 isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != 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 isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != 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 isMatrixWithAllocation(): Boolean = matrixWithAllocation != 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 isGroupedTiered(): Boolean = groupedTiered != 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 asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * 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 asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * 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 asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * 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 asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * Returns the raw JSON value 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 asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Returns the raw JSON value of [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 asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + @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: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** 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() + + @JvmSynthetic + 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 asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** 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: + * ```java + * 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 + } - fun asTieredWithProration(): NewPlanTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * The 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 [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * If the Price represents a fixed cost, the price 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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 asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * Within each billing cycle, specifies the 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 asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - 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) - 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 + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - else -> visitor.unknown(_json) } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun validate(): Percent = apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + private var validated: Boolean = false - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() + fun validate(): Cadence = apply { + if (validated) { + return@apply } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + known() + validated = true + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) { - tieredWithProration.validate() - } + return other is Cadence && value == other.value + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + override fun hashCode() = value.hashCode() - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + override fun toString() = value.toString() + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + @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) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + @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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() + /** 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) } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply } + + percent() + 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. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + override fun hashCode(): Int = hashCode - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - override fun visitBps(bps: NewPlanBpsPrice) = bps.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 visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + fun toBuilder() = Builder().from(this) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + companion object { - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** A builder for [Metadata]. */ + class Builder internal constructor() { - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) = tieredWithProration.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * 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 visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + private var validated: Boolean = false - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + validated = true + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + return other is Metadata && + additionalProperties == other.additionalProperties + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + override fun hashCode(): Int = hashCode - override fun unknown(json: JsonValue?) = 0 + 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 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, + ) } - 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 */ + 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}" } - 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 */ + 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(), + ) - 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") - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - 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") - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = 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") - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - @JvmStatic - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = Price(tieredBps = tieredBps) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - @JvmStatic fun ofBps(bps: NewPlanBpsPrice) = Price(bps = bps) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - @JvmStatic fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = Price(bulkBps = bulkBps) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = 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(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - @JvmStatic - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = - Price(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(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = 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(): Optional = metadata.getOptional("metadata") - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = 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(): Optional = referenceId.getOptional("reference_id") - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = 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 - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * 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 - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * 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 interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * 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 visitUnit(unit: NewPlanUnitPrice): 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 visitPackage(package_: NewPlanPackagePrice): 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 - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** + * Returns the raw JSON value 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 visitTiered(tiered: NewPlanTieredPrice): T + /** + * Returns the raw JSON value of [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 visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitBps(bps: NewPlanBpsPrice): T + @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: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T + /** 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() + + @JvmSynthetic + 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 visitBulk(bulk: NewPlanBulkPrice): T + /** 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 + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): 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. + */ + 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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 visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + /** + * Within each billing cycle, specifies the 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 visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + private var validated: Boolean = false - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + 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. + * 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 Price: $json") - } - } + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - internal class Deserializer : BaseDeserializer(Price::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): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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 (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) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "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) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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().orElseThrow { + OrbInvalidDataException("Value is not a String") } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = 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 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + /** 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 } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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 } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = 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_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "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. + */ + @JvmSynthetic + internal 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.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 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}" } } @@ -5822,12 +19973,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 @@ -5840,10 +20002,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-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index 3d11370f..43090686 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-java-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 @@ -32,12 +33,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** - * 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?, @@ -587,6 +583,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>, @@ -1150,12 +1147,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 @@ -1164,6 +1180,7 @@ private constructor( } class AddAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val planPhaseOrder: JsonField, @@ -1589,10 +1606,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 { @@ -1721,12 +1744,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 @@ -1735,6 +1761,7 @@ private constructor( } class AddPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val planPhaseOrder: JsonField, @@ -1771,7 +1798,7 @@ private constructor( fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("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). @@ -1884,7 +1911,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)) /** Alias for calling [Builder.price] with `price.orElse(null)`. */ @@ -1902,27 +1929,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.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)) + /** 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)`. */ @@ -1937,9 +1955,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 @@ -1948,10 +1973,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)`. */ @@ -1962,6 +1997,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)`. @@ -1976,6 +2015,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)`. @@ -1983,10 +2029,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)`. */ @@ -2022,22 +2064,14 @@ 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.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(Price.ofMinimum(minimum)) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** 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() @@ -2105,31 +2139,32 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.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 tieredBps: NewPlanTieredBpsPrice? = null, - private val bps: NewPlanBpsPrice? = null, - private val bulkBps: NewPlanBulkBpsPrice? = 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? = @@ -2138,27 +2173,21 @@ 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 percent: Percent? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) @@ -2169,13 +2198,22 @@ private constructor( fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) fun packageWithAllocation(): Optional = Optional.ofNullable(packageWithAllocation) - fun tieredWithProration(): Optional = + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) fun unitWithProration(): Optional = @@ -2184,18 +2222,21 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) - fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) @@ -2213,30 +2254,21 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + fun percent(): Optional = Optional.ofNullable(percent) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != null + fun isMatrix(): Boolean = matrix != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -2244,23 +2276,31 @@ private constructor( 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 - 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 @@ -2273,27 +2313,21 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isPercent(): Boolean = percent != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isEventOutput(): Boolean = eventOutput != 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 asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") - fun asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -2304,13 +2338,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 = @@ -2319,18 +2362,21 @@ private constructor( 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 asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") @@ -2346,45 +2392,46 @@ private constructor( fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asPercent(): Percent = percent.getOrThrow("percent") - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): Optional = Optional.ofNullable(_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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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 -> 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 -> @@ -2397,11 +2444,9 @@ 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) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -2418,32 +2463,20 @@ 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() } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() } - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() } override fun visitThresholdTotalAmount( @@ -2462,10 +2495,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( @@ -2474,8 +2511,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() } @@ -2492,6 +2541,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) { @@ -2504,16 +2559,16 @@ private constructor( groupedWithMeteredMinimum.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) { - matrixWithDisplayName.validate() + groupedWithMinMaxThresholds.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) { - bulkWithProration.validate() + matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( @@ -2547,20 +2602,16 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + override fun visitPercent(percent: Percent) { + percent.validate() } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() } } ) @@ -2587,21 +2638,14 @@ 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 visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewPlanBpsPrice) = bps.validity() + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() override fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice @@ -2614,16 +2658,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( @@ -2634,6 +2689,10 @@ private constructor( groupedAllocation: NewPlanGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -2642,14 +2701,14 @@ private constructor( 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() @@ -2671,16 +2730,13 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + override fun visitPercent(percent: Percent) = percent.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2691,38 +2747,102 @@ 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 && + 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 = /* 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, + 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}" - 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}" + 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 -> "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 -> @@ -2733,11 +2853,9 @@ 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}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } @@ -2746,20 +2864,13 @@ private constructor( @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - @JvmStatic - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = Price(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: NewPlanBpsPrice) = Price(bps = bps) + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) - @JvmStatic fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = Price(bulkBps = bulkBps) + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = @@ -2774,8 +2885,13 @@ private constructor( Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic fun ofPackageWithAllocation( @@ -2783,7 +2899,15 @@ private constructor( ) = Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = Price(tieredWithProration = tieredWithProration) @JvmStatic @@ -2794,6 +2918,10 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice @@ -2804,15 +2932,16 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JvmStatic fun ofMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - @JvmStatic fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = Price(groupedTieredPackage = groupedTieredPackage) @@ -2838,17 +2967,12 @@ private constructor( ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -2858,19 +2982,13 @@ private constructor( fun visitUnit(unit: NewPlanUnitPrice): T - fun visitPackage(package_: NewPlanPackagePrice): T - - fun visitMatrix(matrix: NewPlanMatrixPrice): T - fun visitTiered(tiered: NewPlanTieredPrice): T - fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T - - fun visitBps(bps: NewPlanBpsPrice): T + fun visitBulk(bulk: NewPlanBulkPrice): T - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T + fun visitPackage(package_: NewPlanPackagePrice): T - fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitMatrix(matrix: NewPlanMatrixPrice): T fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice @@ -2880,18 +2998,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 @@ -2900,12 +3030,14 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ): T @@ -2926,15 +3058,11 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun visitPercent(percent: Percent): T - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitEventOutput(eventOutput: EventOutput): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -2964,38 +3092,25 @@ 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) } ?: 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) } + "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, @@ -3017,12 +3132,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" -> { @@ -3033,11 +3153,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) } @@ -3057,6 +3190,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, @@ -3073,20 +3214,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" -> { @@ -3129,26 +3270,22 @@ private constructor( ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { + "minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) } } @@ -3165,36 +3302,40 @@ 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.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.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 -> 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 -> @@ -3205,2621 +3346,16631 @@ 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.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 equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddPrice && allocationPrice == other.allocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties /* spotless:on */ - } + 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(), + ) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) } - /* spotless:on */ + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an 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 + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected 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}" - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - 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()) + /** + * 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 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 billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_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(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * 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 + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * 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 per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, 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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - fun toBuilder() = Builder().from(this) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - companion object { + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - private var adjustmentId: 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @JvmSynthetic - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(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(): Optional = referenceId.getOptional("reference_id") - /** - * 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 [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** 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 - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * 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 - /** - * 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: - * ```java - * .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() + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw 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: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + 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 + @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, + ) { + + @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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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( + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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(): Optional = planPhaseOrder.getOptional("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: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (adjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + 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(): Optional = planPhaseOrder.getOptional("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: + * ```java + * .priceId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + 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(): Optional = planPhaseOrder.getOptional("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: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * 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?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + /** 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(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic 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().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + 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(): Optional = + allocationPrice.getOptional("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(): Optional = planPhaseOrder.getOptional("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(): Optional = price.getOptional("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: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * 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?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * 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: + * ```java + * .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().ifPresent { it.validate() } planPhaseOrder() + price().ifPresent { it.validate() } 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.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(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = Price(minimum = minimum) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + 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().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + 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) + } } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (adjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + internal class Serializer : BaseSerializer(Price::class) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + 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") + } + } } - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ - } + 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun hashCode(): Int = hashCode + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("conversion_rate") - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - class RemovePrice - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: 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(): Optional = currency.getOptional("currency") - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, 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(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * 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") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_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(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * 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 + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * 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 + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - 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 [RemovePrice]. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - */ - @JvmStatic 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 [RemovePrice]. */ - class Builder internal constructor() { + /** + * 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 - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmSynthetic - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.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 - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * 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.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Returns the raw JSON value of [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 phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * 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.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 [externalPriceId]. + * + * 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 [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + @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 toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** 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() + + @JvmSynthetic + 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() + } - priceId() - planPhaseOrder() - validated = true - } + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 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. + */ + 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (priceId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - return /* spotless:off */ other is RemovePrice && priceId == other.priceId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(priceId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 hashCode(): Int = hashCode + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @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()) + /** + * Within each billing cycle, specifies the 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. - * - * @throws OrbInvalidDataException if 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 [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 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 additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * 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(): Optional = planPhaseOrder.getOptional("plan_phase_order") + 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) + } - /** - * 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 removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private var validated: Boolean = false - fun toBuilder() = Builder().from(this) + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - companion object { + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.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, + } - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(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 + } - /** - * 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 an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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() - ) + private var validated: Boolean = false - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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() - ) + known() + validated = true + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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 a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + return other is Cadence && value == other.value + } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + override fun hashCode() = value.hashCode() - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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 toString() = value.toString() + } - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * 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 - } + @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) + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + @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: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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() } + } - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * 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) + } + } - /** - * 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 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .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(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + tiers().forEach { it.validate() } + validated = true + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.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) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + @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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** 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, - ) { + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + private var validated: Boolean = false - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + fun validate(): Tier = apply { + if (validated) { + return@apply + } - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + tierLowerBound() + unitAmount() + validated = true + } - fun minimum(): Optional = Optional.ofNullable(minimum) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - fun maximum(): Optional = Optional.ofNullable(maximum) + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + override fun hashCode(): Int = hashCode - fun isUsageDiscount(): Boolean = usageDiscount != null + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - fun isAmountDiscount(): Boolean = amountDiscount != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isMinimum(): Boolean = minimum != null + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun isMaximum(): Boolean = maximum != null + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + override fun hashCode(): Int = hashCode - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, 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(): Optional = Optional.ofNullable(_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]. */ + @JvmStatic 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() + @JvmSynthetic + 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) + } - 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 [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. - */ - @JvmSynthetic - 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. + */ + @JvmSynthetic + 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 + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - return /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + 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 + } - 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, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties, + ) } - companion object { + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + 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}" + } - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + 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, + ) { + + @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(), + ) - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * 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" + ) - @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): 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(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): 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(): Optional = + conversionRate.getOptional("conversion_rate") - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): 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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun visitMinimum(minimum: NewMinimum): 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(): Optional = currency.getOptional("currency") - fun visitMaximum(maximum: NewMaximum): 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(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. + * An alias for the price. * - * 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 externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. * - * @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 fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - 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) - } - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - return Adjustment(_json = json) - } - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - internal class Serializer : BaseSerializer(Adjustment::class) { + /** + * Returns the raw JSON value 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 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 [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 - 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 /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && planPhaseOrder == other.planPhaseOrder && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) } - /* spotless:on */ + /** + * Returns the raw JSON value of [billableMetricId]. + * + * 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(): Int = 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() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$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 - class ReplacePrice - 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 [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("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 [conversionRateConfig]. + * + * 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 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * 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(): Optional = - allocationPrice.getOptional("allocation_price") + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * 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 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(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * 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 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(): Optional = price.getOptional("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 - /** - * 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 [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * 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 [invoicingCycleConfiguration]. + * + * 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 [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 [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 [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 [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) - } + @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) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** 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() + + @JvmSynthetic + 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() + } - companion object { + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic 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 [ReplacePrice]. */ - class Builder internal constructor() { + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 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() + /** + * If the Price represents a fixed cost, the price 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * 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 - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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.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 - } + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Within each billing cycle, specifies the 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 [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * 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 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) + } - /** Alias for calling [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(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 removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewPlanTieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewPlanBpsPrice) = price(Price.ofBps(bps)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewPlanBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> 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.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + private var validated: Boolean = false - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewPlanTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + known() + validated = true + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + return other is Cadence && value == other.value + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + override fun hashCode() = value.hashCode() - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + override fun toString() = value.toString() + } - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** 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 [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + @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) + } - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + @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: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** 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() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** 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 + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** 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 + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** 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 + } - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** 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 + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .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 - private var validated: Boolean = false + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - planPhaseOrder() - price().ifPresent { it.validate() } - 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + 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. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } - /** 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, - ) { + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } - fun unit(): Optional = Optional.ofNullable(unit) + override fun hashCode(): Int = hashCode - fun package_(): Optional = Optional.ofNullable(package_) + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } - fun matrix(): Optional = Optional.ofNullable(matrix) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire 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 tiered(): Optional = Optional.ofNullable(tiered) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) + fun toBuilder() = Builder().from(this) - fun bps(): Optional = Optional.ofNullable(bps) + companion object { - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun bulk(): Optional = Optional.ofNullable(bulk) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + private var additionalProperties: MutableMap = + mutableMapOf() - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun groupedWithProratedMinimum(): Optional = - Optional.ofNullable(groupedWithProratedMinimum) + private var validated: Boolean = false - fun groupedWithMeteredMinimum(): Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + validated = true + } - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + override fun hashCode(): Int = hashCode - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + 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 isUnit(): Boolean = unit != null + 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 isPackage(): Boolean = package_ != null + override fun hashCode(): Int = hashCode - fun isMatrix(): Boolean = matrix != 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 isTiered(): Boolean = tiered != null + 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(), + ) - fun isTieredBps(): Boolean = tieredBps != 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 isBps(): Boolean = bps != 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 isBulkBps(): Boolean = bulkBps != null + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 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 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") - 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(): Optional = + billableMetricId.getOptional("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(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != 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(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun isBulkWithProration(): Boolean = bulkWithProration != 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(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != 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(): Optional = metadata.getOptional("metadata") - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != 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(): Optional = referenceId.getOptional("reference_id") - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != 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 + + /** + * Returns the raw JSON value of [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 - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * 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 isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != 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 isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != 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 isMatrixWithAllocation(): Boolean = matrixWithAllocation != 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 isGroupedTiered(): Boolean = groupedTiered != 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 asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * 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 asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * 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 asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * 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 asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * Returns the raw JSON value 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 asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Returns the raw JSON value of [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 asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + @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: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** 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() + + @JvmSynthetic + 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 asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** 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: + * ```java + * 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 + } - fun asTieredWithProration(): NewPlanTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * The 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 [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * If the Price represents a fixed cost, the price 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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 asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * Within each billing cycle, specifies the 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 asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - 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) - 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 + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - else -> visitor.unknown(_json) } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun validate(): Percent = apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + private var validated: Boolean = false - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() + fun validate(): Cadence = apply { + if (validated) { + return@apply } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + known() + validated = true + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) { - tieredWithProration.validate() - } + return other is Cadence && value == other.value + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + override fun hashCode() = value.hashCode() - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + override fun toString() = value.toString() + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + @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) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + @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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() + /** 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) } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply } + + percent() + 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. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + override fun hashCode(): Int = hashCode - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - override fun visitBps(bps: NewPlanBpsPrice) = bps.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 visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + fun toBuilder() = Builder().from(this) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + companion object { - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** A builder for [Metadata]. */ + class Builder internal constructor() { - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun visitTieredWithProration( - tieredWithProration: NewPlanTierWithProrationPrice - ) = tieredWithProration.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * 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 visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + private var validated: Boolean = false - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + validated = true + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + return other is Metadata && + additionalProperties == other.additionalProperties + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + override fun hashCode(): Int = hashCode - override fun unknown(json: JsonValue?) = 0 + 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 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, + ) } - 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 */ + 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}" } - 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 */ + 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(), + ) - 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") - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - 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") - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = 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") - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - @JvmStatic - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = Price(tieredBps = tieredBps) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - @JvmStatic fun ofBps(bps: NewPlanBpsPrice) = Price(bps = bps) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - @JvmStatic fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = Price(bulkBps = bulkBps) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = 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(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - @JvmStatic - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = - Price(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(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = 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(): Optional = metadata.getOptional("metadata") - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = 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(): Optional = referenceId.getOptional("reference_id") - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = 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 - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * 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 - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * 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 interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * 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 visitUnit(unit: NewPlanUnitPrice): 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 visitPackage(package_: NewPlanPackagePrice): 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 - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** + * Returns the raw JSON value 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 visitTiered(tiered: NewPlanTieredPrice): T + /** + * Returns the raw JSON value of [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 visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitBps(bps: NewPlanBpsPrice): T + @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: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T + /** 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() + + @JvmSynthetic + 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 visitBulk(bulk: NewPlanBulkPrice): T + /** 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 + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): 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. + */ + 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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 visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun visitTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice): T + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + /** + * Within each billing cycle, specifies the 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 visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + private var validated: Boolean = false - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + 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. + * 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 Price: $json") - } - } + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - internal class Deserializer : BaseDeserializer(Price::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): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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 (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) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "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) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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().orElseThrow { + OrbInvalidDataException("Value is not a String") } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = 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 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + /** 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 } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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 } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = 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_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "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. + */ + @JvmSynthetic + internal 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.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 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}" } } @@ -5828,12 +19979,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 @@ -5846,10 +20008,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-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt index bf984e1a..d394b9de 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdFetchPlanVersionParams.kt @@ -213,10 +213,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-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt index a859acaf..ce130e66 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt @@ -273,6 +273,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, @@ -414,12 +415,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 @@ -432,10 +433,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-java-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt index b40d2e80..6c05fae4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaFetchPlanVersionParams.kt @@ -208,10 +208,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-java-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt index 1592ffe2..3141b9e5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt @@ -269,6 +269,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, @@ -410,12 +411,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 @@ -428,10 +429,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-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt index 3fb4a692..b06b0d7c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt @@ -24,6 +24,7 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -439,12 +440,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 @@ -573,7 +572,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() @@ -586,12 +585,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-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt index fd15cdbe..555c0bfd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt +++ b/orb-java-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, @@ -152,12 +153,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-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt index ef218aee..55602b02 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class BillingCycleAnchorConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val day: JsonField, private val month: JsonField, @@ -266,12 +267,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-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt index 4c6d7cc0..30a3aaa6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt @@ -18,6 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class BillingCycleConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val duration: JsonField, private val durationUnit: JsonField, @@ -312,7 +313,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() @@ -325,12 +326,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-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt index 1852fa6b..28f970b2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt @@ -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-java-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt deleted file mode 100644 index 7d7cb73d..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BpsConfig.kt +++ /dev/null @@ -1,220 +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 -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = perUnitMaximum.getOptional("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: - * ```java - * .bps() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.perUnitMaximum] with `perUnitMaximum.orElse(null)`. */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.getOrNull()) - - /** - * 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: - * ```java - * .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. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (bps.asKnown().isPresent) 1 else 0) + (if (perUnitMaximum.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt deleted file mode 100644 index 9592936b..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BpsTier.kt +++ /dev/null @@ -1,308 +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 -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = maximumAmount.getOptional("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(): Optional = perUnitMaximum.getOptional("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: - * ```java - * .bps() - * .minimumAmount() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) - - /** - * 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)) - - /** Alias for calling [Builder.perUnitMaximum] with `perUnitMaximum.orElse(null)`. */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.getOrNull()) - - /** - * 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: - * ```java - * .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. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (bps.asKnown().isPresent) 1 else 0) + - (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (if (perUnitMaximum.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsTier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsTier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt deleted file mode 100644 index 12fb1f03..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfig.kt +++ /dev/null @@ -1,196 +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 -import kotlin.jvm.optionals.getOrNull - -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: - * ```java - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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: - * ```java - * .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. - */ - @JvmSynthetic - internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt deleted file mode 100644 index fc1946e6..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkBpsTier.kt +++ /dev/null @@ -1,266 +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 -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = maximumAmount.getOptional("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(): Optional = perUnitMaximum.getOptional("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: - * ```java - * .bps() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) - - /** - * 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)) - - /** Alias for calling [Builder.perUnitMaximum] with `perUnitMaximum.orElse(null)`. */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.getOrNull()) - - /** - * 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: - * ```java - * .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. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (bps.asKnown().isPresent) 1 else 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (if (perUnitMaximum.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsTier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsTier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt index 5d1ddf97..cf86e68b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt @@ -18,7 +18,9 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Configuration for bulk pricing */ class BulkConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -176,12 +178,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-java-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt index 36802239..0b67361e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt @@ -17,7 +17,9 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Configuration for a single bulk pricing tier */ class BulkTier +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val maximumUnits: JsonField, @@ -215,12 +217,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-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index 34baaea4..a74d5a35 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -6,22 +6,36 @@ 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 +import java.util.Optional import kotlin.jvm.optionals.getOrNull class ChangedSubscriptionResources +@JsonCreator(mode = JsonCreator.Mode.DISABLED) 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, @@ -34,7 +48,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(), @@ -58,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 createdInvoices(): List = createdInvoices.getRequired("created_invoices") + fun createdInvoices(): List = createdInvoices.getRequired("created_invoices") /** * The credit notes that were voided as part of this operation. @@ -93,7 +107,7 @@ private constructor( */ @JsonProperty("created_invoices") @ExcludeMissing - fun _createdInvoices(): JsonField> = createdInvoices + fun _createdInvoices(): JsonField> = createdInvoices /** * Returns the raw JSON value of [voidedCreditNotes]. @@ -146,7 +160,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() @@ -191,26 +205,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) @@ -349,17 +363,7230 @@ private constructor( (voidedCreditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (voidedInvoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class CreatedInvoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amountDue: JsonField, + private val autoCollection: JsonField, + private val billingAddress: JsonField
, + private val createdAt: JsonField, + private val creditNotes: JsonField>, + private val currency: JsonField, + private val customer: JsonField, + private val customerBalanceTransactions: JsonField>, + private val customerTaxId: JsonField, + private val 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, + ) { - return /* spotless:off */ other is ChangedSubscriptionResources && createdCreditNotes == other.createdCreditNotes && createdInvoices == other.createdInvoices && voidedCreditNotes == other.voidedCreditNotes && voidedInvoices == other.voidedInvoices && additionalProperties == other.additionalProperties /* spotless:on */ - } + @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(): Optional
= billingAddress.getOptional("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(): Optional = customerTaxId.getOptional("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(): Optional = dueDate.getOptional("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(): Optional = + eligibleToIssueAt.getOptional("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(): Optional = + hostedInvoiceUrl.getOptional("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(): Optional = invoicePdf.getOptional("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(): Optional = issueFailedAt.getOptional("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(): Optional = issuedAt.getOptional("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(): Optional = maximum.getOptional("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maximumAmount(): Optional = maximumAmount.getOptional("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(): Optional = memo.getOptional("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(): Optional = minimum.getOptional("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun minimumAmount(): Optional = minimumAmount.getOptional("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(): Optional = paidAt.getOptional("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(): Optional = + paymentFailedAt.getOptional("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(): Optional = + paymentStartedAt.getOptional("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(): Optional = + scheduledIssueAt.getOptional("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(): Optional
= shippingAddress.getOptional("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(): Optional = + subscription.getOptional("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(): Optional = syncFailedAt.getOptional("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(): Optional = voidedAt.getOptional("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 - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(createdCreditNotes, createdInvoices, voidedCreditNotes, voidedInvoices, additionalProperties) } - /* spotless:on */ + /** + * 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: + * ```java + * .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() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** Alias for calling [Builder.billingAddress] with `billingAddress.orElse(null)`. */ + fun billingAddress(billingAddress: Optional
) = + billingAddress(billingAddress.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.customerTaxId] with `customerTaxId.orElse(null)`. */ + fun customerTaxId(customerTaxId: Optional) = + customerTaxId(customerTaxId.getOrNull()) + + /** + * 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ + fun dueDate(dueDate: Optional) = dueDate(dueDate.getOrNull()) + + /** + * 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)) + + /** + * Alias for calling [Builder.eligibleToIssueAt] with `eligibleToIssueAt.orElse(null)`. + */ + fun eligibleToIssueAt(eligibleToIssueAt: Optional) = + eligibleToIssueAt(eligibleToIssueAt.getOrNull()) + + /** + * 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)) + + /** + * Alias for calling [Builder.hostedInvoiceUrl] with `hostedInvoiceUrl.orElse(null)`. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: Optional) = + hostedInvoiceUrl(hostedInvoiceUrl.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.invoicePdf] with `invoicePdf.orElse(null)`. */ + fun invoicePdf(invoicePdf: Optional) = invoicePdf(invoicePdf.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.issueFailedAt] with `issueFailedAt.orElse(null)`. */ + fun issueFailedAt(issueFailedAt: Optional) = + issueFailedAt(issueFailedAt.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.issuedAt] with `issuedAt.orElse(null)`. */ + fun issuedAt(issuedAt: Optional) = issuedAt(issuedAt.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ + fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.memo] with `memo.orElse(null)`. */ + fun memo(memo: Optional) = memo(memo.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ + fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.paidAt] with `paidAt.orElse(null)`. */ + fun paidAt(paidAt: Optional) = paidAt(paidAt.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.paymentFailedAt] with `paymentFailedAt.orElse(null)`. */ + fun paymentFailedAt(paymentFailedAt: Optional) = + paymentFailedAt(paymentFailedAt.getOrNull()) + + /** + * 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)) + + /** + * Alias for calling [Builder.paymentStartedAt] with `paymentStartedAt.orElse(null)`. + */ + fun paymentStartedAt(paymentStartedAt: Optional) = + paymentStartedAt(paymentStartedAt.getOrNull()) + + /** + * 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)) + + /** + * Alias for calling [Builder.scheduledIssueAt] with `scheduledIssueAt.orElse(null)`. + */ + fun scheduledIssueAt(scheduledIssueAt: Optional) = + scheduledIssueAt(scheduledIssueAt.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.shippingAddress] with `shippingAddress.orElse(null)`. */ + fun shippingAddress(shippingAddress: Optional
) = + shippingAddress(shippingAddress.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.subscription] with `subscription.orElse(null)`. */ + fun subscription(subscription: Optional) = + subscription(subscription.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.syncFailedAt] with `syncFailedAt.orElse(null)`. */ + fun syncFailedAt(syncFailedAt: Optional) = + syncFailedAt(syncFailedAt.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.voidedAt] with `voidedAt.orElse(null)`. */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.getOrNull()) + + /** + * 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: + * ```java + * .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().ifPresent { it.validate() } + createdAt() + creditNotes().forEach { it.validate() } + currency() + customer().validate() + customerBalanceTransactions().forEach { it.validate() } + customerTaxId().ifPresent { it.validate() } + discounts().forEach { it.validate() } + dueDate() + eligibleToIssueAt() + hostedInvoiceUrl() + invoiceDate() + invoiceNumber() + invoicePdf() + invoiceSource().validate() + isPayableNow() + issueFailedAt() + issuedAt() + lineItems().forEach { it.validate() } + maximum().ifPresent { it.validate() } + maximumAmount() + memo() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + paidAt() + paymentAttempts().forEach { it.validate() } + paymentFailedAt() + paymentStartedAt() + scheduledIssueAt() + shippingAddress().ifPresent { it.validate() } + status().validate() + subscription().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amountDue.asKnown().isPresent) 1 else 0) + + (autoCollection.asKnown().getOrNull()?.validity() ?: 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (customerBalanceTransactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (customerTaxId.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (dueDate.asKnown().isPresent) 1 else 0) + + (if (eligibleToIssueAt.asKnown().isPresent) 1 else 0) + + (if (hostedInvoiceUrl.asKnown().isPresent) 1 else 0) + + (if (invoiceDate.asKnown().isPresent) 1 else 0) + + (if (invoiceNumber.asKnown().isPresent) 1 else 0) + + (if (invoicePdf.asKnown().isPresent) 1 else 0) + + (invoiceSource.asKnown().getOrNull()?.validity() ?: 0) + + (if (isPayableNow.asKnown().isPresent) 1 else 0) + + (if (issueFailedAt.asKnown().isPresent) 1 else 0) + + (if (issuedAt.asKnown().isPresent) 1 else 0) + + (lineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (paidAt.asKnown().isPresent) 1 else 0) + + (paymentAttempts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (paymentFailedAt.asKnown().isPresent) 1 else 0) + + (if (paymentStartedAt.asKnown().isPresent) 1 else 0) + + (if (scheduledIssueAt.asKnown().isPresent) 1 else 0) + + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (syncFailedAt.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + + (if (willAutoIssue.asKnown().isPresent) 1 else 0) + + class AutoCollection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val enabled: JsonField, + private val nextAttemptAt: JsonField, + private val numAttempts: JsonField, + private val previouslyAttemptedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") + @ExcludeMissing + enabled: JsonField = JsonMissing.of(), + @JsonProperty("next_attempt_at") + @ExcludeMissing + nextAttemptAt: JsonField = JsonMissing.of(), + @JsonProperty("num_attempts") + @ExcludeMissing + numAttempts: JsonField = JsonMissing.of(), + @JsonProperty("previously_attempted_at") + @ExcludeMissing + previouslyAttemptedAt: JsonField = JsonMissing.of(), + ) : this(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, mutableMapOf()) + + /** + * True only if auto-collection is enabled for this invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabled(): Optional = enabled.getOptional("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(): Optional = + nextAttemptAt.getOptional("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(): Optional = numAttempts.getOptional("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(): Optional = + previouslyAttemptedAt.getOptional("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: + * ```java + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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?) + + /** Alias for calling [Builder.enabled] with `enabled.orElse(null)`. */ + fun enabled(enabled: Optional) = enabled(enabled.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.nextAttemptAt] with `nextAttemptAt.orElse(null)`. */ + fun nextAttemptAt(nextAttemptAt: Optional) = + nextAttemptAt(nextAttemptAt.getOrNull()) + + /** + * 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?) + + /** Alias for calling [Builder.numAttempts] with `numAttempts.orElse(null)`. */ + fun numAttempts(numAttempts: Optional) = numAttempts(numAttempts.getOrNull()) + + /** + * 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)) + + /** + * Alias for calling [Builder.previouslyAttemptedAt] with + * `previouslyAttemptedAt.orElse(null)`. + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: Optional) = + previouslyAttemptedAt(previouslyAttemptedAt.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (enabled.asKnown().isPresent) 1 else 0) + + (if (nextAttemptAt.asKnown().isPresent) 1 else 0) + + (if (numAttempts.asKnown().isPresent) 1 else 0) + + (if (previouslyAttemptedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoCollection && + enabled == other.enabled && + nextAttemptAt == other.nextAttemptAt && + numAttempts == other.numAttempts && + previouslyAttemptedAt == other.previouslyAttemptedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + enabled, + nextAttemptAt, + numAttempts, + previouslyAttemptedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoCollection{enabled=$enabled, nextAttemptAt=$nextAttemptAt, numAttempts=$numAttempts, previouslyAttemptedAt=$previouslyAttemptedAt, additionalProperties=$additionalProperties}" + } + + class CreditNote + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val creditNoteNumber: JsonField, + private val memo: JsonField, + private val reason: JsonField, + private val total: JsonField, + private val type: JsonField, + private val voidedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("credit_note_number") + @ExcludeMissing + creditNoteNumber: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + voidedAt: JsonField = JsonMissing.of(), + ) : this(id, creditNoteNumber, memo, reason, total, type, voidedAt, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun creditNoteNumber(): String = creditNoteNumber.getRequired("credit_note_number") + + /** + * An optional memo supplied on the credit note. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memo(): Optional = memo.getOptional("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(): Optional = voidedAt.getOptional("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: + * ```java + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** Alias for calling [Builder.memo] with `memo.orElse(null)`. */ + fun memo(memo: Optional) = memo(memo.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.voidedAt] with `voidedAt.orElse(null)`. */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creditNoteNumber.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditNote && + id == other.id && + creditNoteNumber == other.creditNoteNumber && + memo == other.memo && + reason == other.reason && + total == other.total && + type == other.type && + voidedAt == other.voidedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creditNoteNumber, + memo, + reason, + total, + type, + voidedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditNote{id=$id, creditNoteNumber=$creditNoteNumber, memo=$memo, reason=$reason, total=$total, type=$type, voidedAt=$voidedAt, additionalProperties=$additionalProperties}" + } + + class CustomerBalanceTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val action: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val creditNote: JsonField, + private val description: JsonField, + private val endingBalance: JsonField, + private val invoice: JsonField, + private val startingBalance: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_note") + @ExcludeMissing + creditNote: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_balance") + @ExcludeMissing + endingBalance: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + @JsonProperty("starting_balance") + @ExcludeMissing + startingBalance: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + mutableMapOf(), + ) + + /** + * A unique id for this transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun action(): Action = action.getRequired("action") + + /** + * The value of the amount changed in the transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The creation time of this transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditNote(): Optional = creditNote.getOptional("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(): Optional = description.getOptional("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(): Optional = invoice.getOptional("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: + * ```java + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** Alias for calling [Builder.creditNote] with `creditNote.orElse(null)`. */ + fun creditNote(creditNote: Optional) = + creditNote(creditNote.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.invoice] with `invoice.orElse(null)`. */ + fun invoice(invoice: Optional) = invoice(invoice.getOrNull()) + + /** + * 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: + * ```java + * .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().ifPresent { it.validate() } + description() + endingBalance() + invoice().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNote.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Action @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPLIED_TO_INVOICE = of("applied_to_invoice") + + @JvmField val MANUAL_ADJUSTMENT = of("manual_adjustment") + + @JvmField val PRORATED_REFUND = of("prorated_refund") + + @JvmField val REVERT_PRORATED_REFUND = of("revert_prorated_refund") + + @JvmField val RETURN_FROM_VOIDING = of("return_from_voiding") + + @JvmField val CREDIT_NOTE_APPLIED = of("credit_note_applied") + + @JvmField val CREDIT_NOTE_VOIDED = of("credit_note_voided") + + @JvmField val OVERPAYMENT_REFUND = of("overpayment_refund") + + @JvmField val EXTERNAL_PAYMENT = of("external_payment") + + @JvmField val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 { + + @JvmField val INCREMENT = of("increment") + + @JvmField val DECREMENT = of("decrement") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 { + + @JvmField val SUBSCRIPTION = of("subscription") + + @JvmField val PARTIAL = of("partial") + + @JvmField val ONE_OFF = of("one_off") + + @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): InvoiceSource = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceSource && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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(): Optional = discount.getOptional("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(): Optional = filter.getOptional("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(): Optional = grouping.getOptional("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(): Optional = maximum.getOptional("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(): Optional = maximumAmount.getOptional("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(): Optional = minimum.getOptional("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(): Optional = minimumAmount.getOptional("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(): Optional> = + usageCustomerIds.getOptional("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: + * ```java + * .id() + * .adjustedSubtotal() + * .adjustments() + * .amount() + * .creditsApplied() + * .discount() + * .endDate() + * .filter() + * .grouping() + * .maximum() + * .maximumAmount() + * .minimum() + * .minimumAmount() + * .name() + * .partiallyInvoicedAmount() + * .price() + * .quantity() + * .startDate() + * .subLineItems() + * .subtotal() + * .taxAmounts() + * .usageCustomerIds() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ + @Deprecated("deprecated") + fun discount(discount: Optional) = discount(discount.getOrNull()) + + /** + * 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.grouping] with `grouping.orElse(null)`. */ + fun grouping(grouping: Optional) = grouping(grouping.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ + @Deprecated("deprecated") + fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ + @Deprecated("deprecated") + fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * 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)) + + /** 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)) + + /** 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)) + + /** + * Alias for calling [Builder.usageCustomerIds] with + * `usageCustomerIds.orElse(null)`. + */ + fun usageCustomerIds(usageCustomerIds: Optional>) = + usageCustomerIds(usageCustomerIds.getOrNull()) + + /** + * 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: + * ```java + * .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().ifPresent { it.validate() } + endDate() + filter() + grouping() + maximum().ifPresent { it.validate() } + maximumAmount() + minimum().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (adjustedSubtotal.asKnown().isPresent) 1 else 0) + + (adjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (creditsApplied.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (filter.asKnown().isPresent) 1 else 0) + + (if (grouping.asKnown().isPresent) 1 else 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (partiallyInvoicedAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (subLineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (taxAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + 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(): Optional = + Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = + Optional.ofNullable(amountDiscount) + + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic + fun ofUsageDiscount(usageDiscount: MonetaryUsageDiscountAdjustment) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: MonetaryAmountDiscountAdjustment) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic + fun ofPercentageDiscount( + percentageDiscount: MonetaryPercentageDiscountAdjustment + ) = Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofMinimum(minimum: MonetaryMinimumAdjustment) = + Adjustment(minimum = minimum) + + @JvmStatic + 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() + .getOrNull() + ?.get("adjustment_type") + ?.asString() + ?.getOrNull() + + 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(): Optional = Optional.ofNullable(matrix) + + fun tier(): Optional = Optional.ofNullable(tier) + + fun null_(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic + fun ofMatrix(matrix: MatrixSubLineItem) = SubLineItem(matrix = matrix) + + @JvmStatic fun ofTier(tier: TierSubLineItem) = SubLineItem(tier = tier) + + @JvmStatic 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().getOrNull()?.get("type")?.asString()?.getOrNull() + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PaymentAttempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val paymentProvider: JsonField, + private val paymentProviderId: JsonField, + private val receiptPdf: JsonField, + private val succeeded: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("receipt_pdf") + @ExcludeMissing + receiptPdf: JsonField = JsonMissing.of(), + @JsonProperty("succeeded") + @ExcludeMissing + succeeded: JsonField = JsonMissing.of(), + ) : this( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + receiptPdf, + succeeded, + mutableMapOf(), + ) + + /** + * The ID of the payment attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The amount of the payment attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The time at which the payment attempt was created. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The payment provider that attempted to collect the payment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProvider(): Optional = + paymentProvider.getOptional("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(): Optional = + paymentProviderId.getOptional("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(): Optional = receiptPdf.getOptional("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: + * ```java + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .receiptPdf() + * .succeeded() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.paymentProvider] with `paymentProvider.orElse(null)`. + */ + fun paymentProvider(paymentProvider: Optional) = + paymentProvider(paymentProvider.getOrNull()) + + /** + * 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)) + + /** + * Alias for calling [Builder.paymentProviderId] with + * `paymentProviderId.orElse(null)`. + */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.receiptPdf] with `receiptPdf.orElse(null)`. */ + fun receiptPdf(receiptPdf: Optional) = receiptPdf(receiptPdf.getOrNull()) + + /** + * 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: + * ```java + * .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().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (if (receiptPdf.asKnown().isPresent) 1 else 0) + + (if (succeeded.asKnown().isPresent) 1 else 0) + + /** 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 { + + @JvmField val STRIPE = of("stripe") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): PaymentProvider = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 { + + @JvmField val ISSUED = of("issued") + + @JvmField val PAID = of("paid") + + @JvmField val SYNCED = of("synced") + + @JvmField val VOID = of("void") + + @JvmField val DRAFT = of("draft") + + @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 + } + + return other is ChangedSubscriptionResources && + createdCreditNotes == other.createdCreditNotes && + createdInvoices == other.createdInvoices && + voidedCreditNotes == other.voidedCreditNotes && + voidedInvoices == other.voidedInvoices && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + createdCreditNotes, + createdInvoices, + voidedCreditNotes, + voidedInvoices, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt new file mode 100644 index 00000000..ae82e68e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt @@ -0,0 +1,188 @@ +// 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 +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@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(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + + @JvmStatic + 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().getOrNull()?.get("conversion_rate_type")?.asString()?.getOrNull() + + 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-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt index 7c452609..18fbc520 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class ConversionRateTier +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstUnit: JsonField, private val unitAmount: JsonField, @@ -244,12 +245,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-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt index d79d5412..6f337adb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class ConversionRateTieredConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -178,12 +179,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-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt index f49136e5..2f055ec6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt +++ b/orb-java-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, @@ -161,12 +162,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-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt index 3f280e85..58583949 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt @@ -35,6 +35,7 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -589,10 +590,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 { @@ -680,12 +681,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-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt index d317ce98..d459babc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt @@ -218,10 +218,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-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt index f431191f..3f2b4087 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt @@ -408,6 +408,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, @@ -745,12 +746,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 @@ -840,10 +852,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 { @@ -925,6 +937,7 @@ private constructor( } class Percentage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonValue, private val percentageDiscount: JsonField, @@ -1122,12 +1135,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 @@ -1136,6 +1152,7 @@ private constructor( } class Amount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountDiscount: JsonField, private val discountType: JsonValue, @@ -1333,12 +1350,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 @@ -1352,10 +1372,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-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt index 8066c76f..df89104b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt @@ -179,10 +179,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-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt index b4f0db15..26f537bc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt index 5060fab6..5d737a93 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt @@ -134,10 +134,14 @@ private constructor( return true } - return /* spotless:off */ other is CouponListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CouponListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CouponListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt index 77a5bcc3..a6d3b342 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CouponListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -217,12 +218,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-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt index 709c61df..5cd99644 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt @@ -253,10 +253,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-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt index 39af902b..525f23c7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CouponRedemption +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val couponId: JsonField, private val endDate: JsonField, @@ -235,12 +236,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-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt index 4b875933..3f9dae46 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt index 25bbffb5..9b5bb6a4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt @@ -137,10 +137,14 @@ private constructor( return true } - return /* spotless:off */ other is CouponSubscriptionListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CouponSubscriptionListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CouponSubscriptionListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt index 7325ed40..93358050 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt @@ -233,10 +233,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-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt index a2691f89..046f82f8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CreditBlockExpiryLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -742,7 +743,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() @@ -862,7 +863,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() @@ -964,12 +965,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 @@ -981,12 +980,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-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt index 1e2e7f60..b672de48 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt @@ -26,6 +26,7 @@ import kotlin.jvm.optionals.getOrNull * a particular invoice. */ class CreditNote +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -815,6 +816,7 @@ private constructor( (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -1368,6 +1370,7 @@ private constructor( (if (startTimeInclusive.asKnown().isPresent) 1 else 0) class Discount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amountApplied: JsonField, @@ -1906,7 +1909,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() @@ -1919,13 +1922,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() = @@ -1937,12 +1957,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 @@ -1952,6 +1995,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, @@ -2390,7 +2434,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() @@ -2399,6 +2443,7 @@ private constructor( } class AppliesToPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, @@ -2579,12 +2624,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 @@ -2597,12 +2643,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 @@ -2738,7 +2797,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() @@ -2862,7 +2921,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() @@ -2871,6 +2930,7 @@ private constructor( } class Discount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountApplied: JsonField, private val discountType: JsonField, @@ -3309,7 +3369,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() @@ -3318,6 +3378,7 @@ private constructor( } class AppliesToPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, @@ -3498,12 +3559,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 @@ -3516,12 +3578,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 @@ -3534,12 +3609,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-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt index ab9d8243..5a9e4b4b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt @@ -413,6 +413,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, @@ -743,12 +744,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 @@ -757,6 +764,7 @@ private constructor( } class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val invoiceLineItemId: JsonField, @@ -1043,12 +1051,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 @@ -1185,7 +1198,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() @@ -1198,10 +1211,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-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt index 4ded1cfc..3b1626dd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt @@ -183,10 +183,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-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt index da30dc53..911bccbd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt index f65c79cf..cba4d781 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt @@ -135,10 +135,14 @@ private constructor( return true } - return /* spotless:off */ other is CreditNoteListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CreditNoteListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CreditNoteListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt index c9e73d4b..b386ac9f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CreditNoteListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -217,12 +218,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-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt index 5d66a657..288a906d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt @@ -275,10 +275,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-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt index 588aace4..ae490e89 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt +++ b/orb-java-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, @@ -155,12 +156,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-java-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt index 31f5aaff..3b4decd0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt @@ -18,6 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomExpiration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val duration: JsonField, private val durationUnit: JsonField, @@ -312,7 +313,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() @@ -325,12 +326,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-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt index 8352f85c..8f3cdb57 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -40,10 +40,12 @@ import kotlin.jvm.optionals.getOrNull * timezone parameter influences within Orb. */ class Customer +@JsonCreator(mode = JsonCreator.Mode.DISABLED) 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, @@ -75,6 +77,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 @@ -120,6 +125,7 @@ private constructor( id, additionalEmails, autoCollection, + autoIssuance, balance, billingAddress, createdAt, @@ -160,6 +166,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(): Optional = autoIssuance.getOptional("auto_issuance") + /** * The customer's current balance in their currency. * @@ -349,9 +365,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 | @@ -476,6 +492,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]. * @@ -657,6 +682,7 @@ private constructor( * .id() * .additionalEmails() * .autoCollection() + * .autoIssuance() * .balance() * .billingAddress() * .createdAt() @@ -685,6 +711,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 @@ -712,6 +739,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 @@ -783,6 +811,34 @@ 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?) + + /** Alias for calling [Builder.autoIssuance] with `autoIssuance.orElse(null)`. */ + fun autoIssuance(autoIssuance: Optional) = autoIssuance(autoIssuance.getOrNull()) + + /** + * 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)) @@ -1105,9 +1161,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 | @@ -1279,6 +1335,7 @@ private constructor( * .id() * .additionalEmails() * .autoCollection() + * .autoIssuance() * .balance() * .billingAddress() * .createdAt() @@ -1305,6 +1362,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), @@ -1338,6 +1396,7 @@ private constructor( id() additionalEmails() autoCollection() + autoIssuance() balance() billingAddress().ifPresent { it.validate() } createdAt() @@ -1378,6 +1437,7 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (additionalEmails.asKnown().getOrNull()?.size ?: 0) + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (autoIssuance.asKnown().isPresent) 1 else 0) + (if (balance.asKnown().isPresent) 1 else 0) + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -1400,6 +1460,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, @@ -1599,12 +1660,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 @@ -1706,12 +1768,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 @@ -1860,7 +1920,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() @@ -1869,6 +1929,7 @@ private constructor( } class AccountingSyncConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountingProviders: JsonField>, private val excluded: JsonField, @@ -2070,6 +2131,7 @@ private constructor( (if (excluded.asKnown().isPresent) 1 else 0) class AccountingProvider + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalProviderId: JsonField, private val providerType: JsonField, @@ -2394,7 +2456,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() @@ -2407,12 +2469,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 @@ -2425,12 +2490,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 @@ -2439,6 +2507,7 @@ private constructor( } class ReportingConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val exempt: JsonField, private val additionalProperties: MutableMap, @@ -2580,12 +2649,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 @@ -2598,15 +2667,64 @@ 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 && + autoIssuance == other.autoIssuance && + 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, + autoIssuance, + 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 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-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt index e4ed0a93..57f6754d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt @@ -323,6 +323,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, @@ -542,12 +543,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 @@ -671,7 +676,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() @@ -684,10 +689,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt index 32b81809..0d952579 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerBalanceTransactionCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val action: JsonField, @@ -557,6 +558,8 @@ private constructor( @JvmField val EXTERNAL_PAYMENT = of("external_payment") + @JvmField val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) } @@ -571,6 +574,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, } /** @@ -592,6 +596,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, } @@ -614,6 +619,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 } @@ -636,6 +642,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") } @@ -683,7 +690,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() @@ -807,7 +814,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() @@ -820,12 +827,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt index 3bb12c25..b995c3a2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt @@ -129,10 +129,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt index e032ad33..61e1db63 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt @@ -144,10 +144,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransactionListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CustomerBalanceTransactionListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CustomerBalanceTransactionListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt index 3cc541d8..650f4c7a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerBalanceTransactionListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -225,12 +226,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt index ff73a975..afd822ae 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt @@ -321,10 +321,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt index 5b8f4918..c265e6ed 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerBalanceTransactionListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val action: JsonField, @@ -557,6 +558,8 @@ private constructor( @JvmField val EXTERNAL_PAYMENT = of("external_payment") + @JvmField val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) } @@ -571,6 +574,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, } /** @@ -592,6 +596,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, } @@ -614,6 +619,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 } @@ -636,6 +642,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") } @@ -683,7 +690,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() @@ -807,7 +814,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() @@ -820,12 +827,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt index f359624d..d9318231 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt @@ -35,7 +35,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -48,17 +47,15 @@ import kotlin.jvm.optionals.getOrNull * 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. * @@ -76,7 +73,6 @@ import kotlin.jvm.optionals.getOrNull * | 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 @@ -86,7 +82,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -117,7 +112,6 @@ import kotlin.jvm.optionals.getOrNull * 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` @@ -496,7 +490,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() @@ -509,10 +503,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt index 2748d668..86d9cce3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerCostListByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -181,12 +182,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt index cb2b74ef..729730f4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt @@ -35,7 +35,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -48,17 +47,15 @@ import kotlin.jvm.optionals.getOrNull * 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. * @@ -76,7 +73,6 @@ import kotlin.jvm.optionals.getOrNull * | 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 @@ -86,7 +82,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -117,7 +112,6 @@ import kotlin.jvm.optionals.getOrNull * 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` @@ -486,7 +480,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() @@ -499,10 +493,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt index cb0ee2f6..40d19b19 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerCostListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -177,12 +178,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index b7f27ed3..23b3722d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -38,11 +38,11 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -78,7 +78,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). @@ -95,6 +96,17 @@ private constructor( */ fun autoCollection(): Optional = 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(): Optional = body.autoIssuance() + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -254,9 +266,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 | @@ -379,6 +391,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]. * @@ -577,7 +596,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) @@ -636,6 +656,35 @@ 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?) + + /** Alias for calling [Builder.autoIssuance] with `autoIssuance.orElse(null)`. */ + fun autoIssuance(autoIssuance: Optional) = autoIssuance(autoIssuance.getOrNull()) + + /** + * 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) } @@ -920,6 +969,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: + * ```java + * 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. @@ -993,9 +1059,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 | @@ -1242,12 +1308,14 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val email: JsonField, private val name: JsonField, 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, @@ -1278,6 +1346,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(), @@ -1321,6 +1392,7 @@ private constructor( accountingSyncConfiguration, additionalEmails, autoCollection, + autoIssuance, billingAddress, currency, emailDelivery, @@ -1363,7 +1435,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). @@ -1381,6 +1454,17 @@ private constructor( */ fun autoCollection(): Optional = autoCollection.getOptional("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(): Optional = autoIssuance.getOptional("auto_issuance") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1545,9 +1629,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 | @@ -1677,6 +1761,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]. * @@ -1829,6 +1923,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() @@ -1852,6 +1947,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 @@ -1921,7 +2017,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)) @@ -1985,6 +2082,37 @@ 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?) + + /** Alias for calling [Builder.autoIssuance] with `autoIssuance.orElse(null)`. */ + fun autoIssuance(autoIssuance: Optional) = + autoIssuance(autoIssuance.getOrNull()) + + /** + * 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)) @@ -2279,6 +2407,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: + * ```java + * 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. @@ -2352,9 +2495,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 | @@ -2496,6 +2639,7 @@ private constructor( accountingSyncConfiguration, (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, + autoIssuance, billingAddress, currency, emailDelivery, @@ -2525,6 +2669,7 @@ private constructor( accountingSyncConfiguration().ifPresent { it.validate() } additionalEmails() autoCollection() + autoIssuance() billingAddress().ifPresent { it.validate() } currency() emailDelivery() @@ -2562,6 +2707,7 @@ private constructor( (accountingSyncConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (additionalEmails.asKnown().getOrNull()?.size ?: 0) + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (autoIssuance.asKnown().isPresent) 1 else 0) + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (emailDelivery.asKnown().isPresent) 1 else 0) + @@ -2581,17 +2727,58 @@ 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 && + autoIssuance == other.autoIssuance && + 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, + autoIssuance, + 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() = - "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}" } /** @@ -2688,12 +2875,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 @@ -2842,7 +3027,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() @@ -2857,6 +3042,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, ) { @@ -2866,18 +3052,24 @@ private constructor( fun sphere(): Optional = Optional.ofNullable(sphere) + fun numeral(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -2885,6 +3077,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) } @@ -2908,6 +3101,10 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) { sphere.validate() } + + override fun visitNumeral(numeral: Numeral) { + numeral.validate() + } } ) validated = true @@ -2938,6 +3135,8 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) = sphere.validity() + override fun visitNumeral(numeral: Numeral) = numeral.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2947,16 +3146,21 @@ 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 && + numeral == other.numeral } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalara, taxjar, sphere) /* spotless:on */ + 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") } @@ -2971,6 +3175,8 @@ private constructor( @JvmStatic fun ofSphere(sphere: NewSphereConfiguration) = TaxConfiguration(sphere = sphere) + + @JvmStatic fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) } /** @@ -2985,6 +3191,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]. * @@ -3023,6 +3231,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) @@ -3040,11 +3253,222 @@ 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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: + * ```java + * 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: + * ```java + * .taxExempt() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (taxExempt.asKnown().isPresent) 1 else 0) + + 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 { @@ -3052,10 +3476,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 530801a5..0152d800 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -50,7 +50,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -74,7 +73,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -82,7 +80,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -100,7 +97,6 @@ import kotlin.jvm.optionals.getOrNull * ``` * * ## 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 @@ -508,10 +504,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 { @@ -625,6 +627,7 @@ private constructor( } class Increment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val entryType: JsonValue, @@ -1179,9 +1182,11 @@ 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, + private val customDueDate: JsonField, private val invoiceDate: JsonField, private val memo: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1196,6 +1201,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(), @@ -1208,6 +1216,7 @@ private constructor( ) : this( autoCollection, netTerms, + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1225,15 +1234,27 @@ 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(): Optional = netTerms.getOptional("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(): Optional = + customDueDate.getOptional("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 @@ -1282,6 +1303,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]. * @@ -1341,6 +1372,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() @@ -1350,6 +1382,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 @@ -1375,9 +1408,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)) @@ -1400,6 +1436,39 @@ 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)) + + /** + * Alias for calling [Builder.customDueDate] with `customDueDate.orElse(null)`. + */ + fun customDueDate(customDueDate: Optional) = + customDueDate(customDueDate.getOrNull()) + + /** + * 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 @@ -1503,6 +1572,7 @@ private constructor( InvoiceSettings( checkRequired("autoCollection", autoCollection), checkRequired("netTerms", netTerms), + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1519,6 +1589,7 @@ private constructor( autoCollection() netTerms() + customDueDate().ifPresent { it.validate() } invoiceDate().ifPresent { it.validate() } memo() requireSuccessfulPayment() @@ -1543,10 +1614,192 @@ private constructor( internal fun validity(): Int = (if (autoCollection.asKnown().isPresent) 1 else 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (customDueDate.asKnown().getOrNull()?.validity() ?: 0) + (invoiceDate.asKnown().getOrNull()?.validity() ?: 0) + (if (memo.asKnown().isPresent) 1 else 0) + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + /** + * 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(): Optional = Optional.ofNullable(date) + + fun dateTime(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic fun ofDate(date: LocalDate) = CustomDueDate(date = date) + + @JvmStatic + 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 @@ -1630,10 +1883,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 { @@ -1730,17 +1985,32 @@ 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 && + customDueDate == other.customDueDate && + 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, + customDueDate, + invoiceDate, + memo, + requireSuccessfulPayment, + additionalProperties, + ) + } 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}" } /** @@ -1842,12 +2112,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 @@ -1859,12 +2127,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 @@ -1873,6 +2162,7 @@ private constructor( } class Decrement + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val entryType: JsonValue, @@ -2303,12 +2593,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 @@ -2320,12 +2608,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 @@ -2334,6 +2635,7 @@ private constructor( } class ExpirationChange + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val entryType: JsonValue, private val targetExpiryDate: JsonField, @@ -2922,12 +3224,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 @@ -2939,12 +3239,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 @@ -2953,6 +3272,7 @@ private constructor( } class Void + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val blockId: JsonField, @@ -3477,12 +3797,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 @@ -3608,7 +3926,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() @@ -3621,12 +3939,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 @@ -3635,6 +3970,7 @@ private constructor( } class Amendment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val blockId: JsonField, @@ -4104,12 +4440,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 @@ -4121,12 +4455,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 @@ -4140,10 +4489,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt index 9e73844d..b8277061 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt @@ -183,10 +183,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 8313ff1b..f93221c0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -50,7 +50,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -74,7 +73,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -82,7 +80,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -100,7 +97,6 @@ import kotlin.jvm.optionals.getOrNull * ``` * * ## 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 @@ -500,10 +496,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 { @@ -617,6 +619,7 @@ private constructor( } class Increment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val entryType: JsonValue, @@ -1171,9 +1174,11 @@ 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, + private val customDueDate: JsonField, private val invoiceDate: JsonField, private val memo: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1188,6 +1193,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(), @@ -1200,6 +1208,7 @@ private constructor( ) : this( autoCollection, netTerms, + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1217,15 +1226,27 @@ 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(): Optional = netTerms.getOptional("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(): Optional = + customDueDate.getOptional("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 @@ -1274,6 +1295,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]. * @@ -1333,6 +1364,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() @@ -1342,6 +1374,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 @@ -1367,9 +1400,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)) @@ -1392,6 +1428,39 @@ 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)) + + /** + * Alias for calling [Builder.customDueDate] with `customDueDate.orElse(null)`. + */ + fun customDueDate(customDueDate: Optional) = + customDueDate(customDueDate.getOrNull()) + + /** + * 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 @@ -1495,6 +1564,7 @@ private constructor( InvoiceSettings( checkRequired("autoCollection", autoCollection), checkRequired("netTerms", netTerms), + customDueDate, invoiceDate, memo, requireSuccessfulPayment, @@ -1511,6 +1581,7 @@ private constructor( autoCollection() netTerms() + customDueDate().ifPresent { it.validate() } invoiceDate().ifPresent { it.validate() } memo() requireSuccessfulPayment() @@ -1535,10 +1606,192 @@ private constructor( internal fun validity(): Int = (if (autoCollection.asKnown().isPresent) 1 else 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + + (customDueDate.asKnown().getOrNull()?.validity() ?: 0) + (invoiceDate.asKnown().getOrNull()?.validity() ?: 0) + (if (memo.asKnown().isPresent) 1 else 0) + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) + /** + * 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(): Optional = Optional.ofNullable(date) + + fun dateTime(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic fun ofDate(date: LocalDate) = CustomDueDate(date = date) + + @JvmStatic + 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 @@ -1622,10 +1875,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 { @@ -1722,17 +1977,32 @@ 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 && + customDueDate == other.customDueDate && + 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, + customDueDate, + invoiceDate, + memo, + requireSuccessfulPayment, + additionalProperties, + ) + } 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}" } /** @@ -1834,12 +2104,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 @@ -1851,12 +2119,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 @@ -1865,6 +2154,7 @@ private constructor( } class Decrement + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val entryType: JsonValue, @@ -2295,12 +2585,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 @@ -2312,12 +2600,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 @@ -2326,6 +2627,7 @@ private constructor( } class ExpirationChange + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val entryType: JsonValue, private val targetExpiryDate: JsonField, @@ -2914,12 +3216,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 @@ -2931,12 +3231,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 @@ -2945,6 +3264,7 @@ private constructor( } class Void + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val blockId: JsonField, @@ -3469,12 +3789,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 @@ -3600,7 +3918,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() @@ -3613,12 +3931,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 @@ -3627,6 +3962,7 @@ private constructor( } class Amendment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val blockId: JsonField, @@ -4096,12 +4432,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 @@ -4113,12 +4447,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 @@ -4132,10 +4481,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt index f8d42347..5bcd947d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt @@ -183,10 +183,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt index d997a531..56e5b7db 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt @@ -133,10 +133,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt index b32ca622..e74696da 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt @@ -148,10 +148,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditLedgerListByExternalIdPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CustomerCreditLedgerListByExternalIdPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt index 07c99ee6..29ac9ad8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerCreditLedgerListByExternalIdPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -281,12 +282,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt index 72f2438b..f60e9739 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt @@ -26,14 +26,12 @@ import kotlin.jvm.optionals.getOrNull * 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. @@ -45,13 +43,13 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -61,34 +59,29 @@ import kotlin.jvm.optionals.getOrNull * a result of a decrement. * * ## Expiration change - * * The expiry of credits can be changed as a result of the API (See * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the * balance as well as the initial and target expiry dates. * * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` * represents the balance transferred. The credit block linked to the ledger entry is the source - * credit block from which there was an expiration change + * 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. */ @@ -545,7 +538,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() @@ -701,7 +694,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() @@ -714,10 +707,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt index 8bc3878a..4d45fef8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt @@ -183,10 +183,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt index a45c5459..98632ee3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt @@ -125,10 +125,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt index 11dee7e0..2f908f3e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt @@ -141,10 +141,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditLedgerListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CustomerCreditLedgerListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt index 2a05e677..b12e38cb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerCreditLedgerListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -271,12 +272,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt index 7ecb7e23..b6a021be 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt @@ -26,14 +26,12 @@ import kotlin.jvm.optionals.getOrNull * 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. @@ -45,13 +43,13 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -61,34 +59,29 @@ import kotlin.jvm.optionals.getOrNull * a result of a decrement. * * ## Expiration change - * * The expiry of credits can be changed as a result of the API (See * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the * balance as well as the initial and target expiry dates. * * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` * represents the balance transferred. The credit block linked to the ledger entry is the source - * credit block from which there was an expiration change + * 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. */ @@ -536,7 +529,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() @@ -692,7 +685,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() @@ -705,10 +698,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt index 3e84da92..d976e82f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt @@ -183,10 +183,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt index 03e2ad77..30036a16 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt @@ -130,10 +130,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt index a814d8ab..455f25e3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt @@ -144,10 +144,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListByExternalIdPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditListByExternalIdPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CustomerCreditListByExternalIdPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt index 660e69c6..901f2f72 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerCreditListByExternalIdPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -225,12 +226,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt index c025c956..a4a0cf20 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt @@ -289,10 +289,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index 6a860d1b..eddd47b2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerCreditListByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val balance: JsonField, @@ -537,7 +538,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() @@ -550,12 +551,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt index 8e552028..0ed69533 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt @@ -123,10 +123,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt index 2394a3ef..5d10b44f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt @@ -137,10 +137,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CustomerCreditListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt index ff42399a..e316012e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerCreditListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -223,12 +224,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt index 0635c992..1819ee0c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt @@ -278,10 +278,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index bcd4467e..ef188586 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerCreditListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val balance: JsonField, @@ -533,7 +534,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() @@ -546,12 +547,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt index bf4d41e8..c2a52962 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt @@ -530,6 +530,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,12 +1012,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 @@ -1026,6 +1046,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, @@ -1311,12 +1332,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 @@ -1445,7 +1477,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() @@ -1458,10 +1490,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt index 84b7a9cb..e43937f1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerCreditTopUpCreateByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -591,7 +592,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() @@ -604,12 +605,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt index 29ca050f..b81a4b6d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt @@ -523,6 +523,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, @@ -1004,12 +1005,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 @@ -1019,6 +1039,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, @@ -1304,12 +1325,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 @@ -1438,7 +1470,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() @@ -1451,10 +1483,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt index f3af1edc..9340d191 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerCreditTopUpCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -589,7 +590,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() @@ -602,12 +603,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt index 049eb857..6598df31 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt @@ -247,10 +247,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt index 0fd71b2a..d22c3438 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt @@ -243,10 +243,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt index e22c6e32..157ee844 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt @@ -133,10 +133,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt index bcc25def..f7516ac1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt @@ -148,10 +148,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditTopUpListByExternalIdPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CustomerCreditTopUpListByExternalIdPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt index e35ef34f..f0f22749 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerCreditTopUpListByExternalIdPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -227,12 +228,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt index 63e03539..25c4c29b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt @@ -238,10 +238,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt index 9f84de18..2fe145ba 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerCreditTopUpListByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -590,7 +591,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() @@ -603,12 +604,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt index 9255d0bb..42e00197 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt @@ -125,10 +125,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt index cc11835e..ea817379 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt @@ -141,10 +141,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CustomerCreditTopUpListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CustomerCreditTopUpListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt index ef5bf608..03bbd399 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerCreditTopUpListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -225,12 +226,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt index 1e497cf8..683512ab 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt @@ -229,10 +229,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt index ab16e710..78f8c707 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerCreditTopUpListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -589,7 +590,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() @@ -602,12 +603,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt index 47617e22..fbbc79b8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt @@ -225,10 +225,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt index f29330af..534bc8a7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt @@ -196,10 +196,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt index 79139103..1e6d6754 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt @@ -185,10 +185,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt index 58a295da..b935befe 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerHierarchyConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val childCustomerIds: JsonField>, private val parentCustomerId: JsonField, @@ -225,12 +226,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt index 07c35cf0..b61e32eb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt index 4508ba61..116dd08a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt @@ -135,10 +135,14 @@ private constructor( return true } - return /* spotless:off */ other is CustomerListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is CustomerListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "CustomerListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt index 2c04b338..e28c0042 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class CustomerListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -217,12 +218,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt index 847e1cea..a10f68ce 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt @@ -277,10 +277,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt index 023cc6c7..ff8e0eb4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CustomerMinified +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val externalCustomerId: JsonField, @@ -207,12 +208,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt index 7b761fbe..b09cc75b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt @@ -244,10 +244,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt index 3a012ac9..9ec305e3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt @@ -229,10 +229,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt index d65604b7..09bcbb95 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt @@ -90,9 +90,9 @@ import kotlin.jvm.optionals.getOrNull * |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 | @@ -163,6 +163,7 @@ import kotlin.jvm.optionals.getOrNull * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | */ class CustomerTaxId +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val country: JsonField, private val type: JsonField, @@ -1139,7 +1140,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() @@ -1911,7 +1912,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() @@ -1924,12 +1925,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 657c7943..c4fdfa05 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -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 @@ -56,7 +57,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). @@ -73,6 +75,17 @@ private constructor( */ fun autoCollection(): Optional = 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(): Optional = body.autoIssuance() + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -252,9 +265,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 | @@ -353,6 +366,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]. * @@ -508,8 +528,8 @@ private constructor( * - [accountingSyncConfiguration] * - [additionalEmails] * - [autoCollection] + * - [autoIssuance] * - [billingAddress] - * - [currency] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -539,7 +559,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) @@ -598,6 +619,35 @@ 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?) + + /** Alias for calling [Builder.autoIssuance] with `autoIssuance.orElse(null)`. */ + fun autoIssuance(autoIssuance: Optional) = autoIssuance(autoIssuance.getOrNull()) + + /** + * 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) } @@ -914,6 +964,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: + * ```java + * 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. @@ -987,9 +1054,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 | @@ -1217,10 +1284,12 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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, @@ -1250,6 +1319,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(), @@ -1292,6 +1364,7 @@ private constructor( accountingSyncConfiguration, additionalEmails, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -1318,7 +1391,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). @@ -1336,6 +1410,17 @@ private constructor( */ fun autoCollection(): Optional = autoCollection.getOptional("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(): Optional = autoIssuance.getOptional("auto_issuance") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1520,9 +1605,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 | @@ -1628,6 +1713,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]. * @@ -1777,6 +1872,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() @@ -1799,6 +1895,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 @@ -1841,7 +1938,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)) @@ -1905,6 +2003,37 @@ 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?) + + /** Alias for calling [Builder.autoIssuance] with `autoIssuance.orElse(null)`. */ + fun autoIssuance(autoIssuance: Optional) = + autoIssuance(autoIssuance.getOrNull()) + + /** + * 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)) @@ -2234,6 +2363,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: + * ```java + * 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. @@ -2307,9 +2451,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 | @@ -2422,6 +2566,7 @@ private constructor( accountingSyncConfiguration, (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -2450,6 +2595,7 @@ private constructor( accountingSyncConfiguration().ifPresent { it.validate() } additionalEmails() autoCollection() + autoIssuance() billingAddress().ifPresent { it.validate() } currency() email() @@ -2486,6 +2632,7 @@ private constructor( (accountingSyncConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (additionalEmails.asKnown().getOrNull()?.size ?: 0) + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (autoIssuance.asKnown().isPresent) 1 else 0) + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (email.asKnown().isPresent) 1 else 0) + @@ -2506,17 +2653,56 @@ 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 && + autoIssuance == other.autoIssuance && + 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, + autoIssuance, + 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() = - "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}" } /** @@ -2613,12 +2799,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 @@ -2770,7 +2954,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() @@ -2785,6 +2969,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, ) { @@ -2794,18 +2979,24 @@ private constructor( fun sphere(): Optional = Optional.ofNullable(sphere) + fun numeral(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -2813,6 +3004,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) } @@ -2836,6 +3028,10 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) { sphere.validate() } + + override fun visitNumeral(numeral: Numeral) { + numeral.validate() + } } ) validated = true @@ -2866,6 +3062,8 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) = sphere.validity() + override fun visitNumeral(numeral: Numeral) = numeral.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2875,16 +3073,21 @@ 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 && + numeral == other.numeral } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalara, taxjar, sphere) /* spotless:on */ + 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") } @@ -2899,6 +3102,8 @@ private constructor( @JvmStatic fun ofSphere(sphere: NewSphereConfiguration) = TaxConfiguration(sphere = sphere) + + @JvmStatic fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) } /** @@ -2913,6 +3118,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]. * @@ -2951,6 +3158,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) @@ -2968,11 +3180,222 @@ 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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: + * ```java + * 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: + * ```java + * .taxExempt() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (taxExempt.asKnown().isPresent) 1 else 0) + + 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 { @@ -2980,10 +3403,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-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 8f603ade..ad0498a1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -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 @@ -57,7 +58,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). @@ -74,6 +76,17 @@ private constructor( */ fun autoCollection(): Optional = 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(): Optional = body.autoIssuance() + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -253,9 +266,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 | @@ -354,6 +367,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]. * @@ -504,8 +524,8 @@ private constructor( * - [accountingSyncConfiguration] * - [additionalEmails] * - [autoCollection] + * - [autoIssuance] * - [billingAddress] - * - [currency] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -535,7 +555,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) @@ -594,6 +615,35 @@ 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?) + + /** Alias for calling [Builder.autoIssuance] with `autoIssuance.orElse(null)`. */ + fun autoIssuance(autoIssuance: Optional) = autoIssuance(autoIssuance.getOrNull()) + + /** + * 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) } @@ -910,6 +960,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: + * ```java + * 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. @@ -983,9 +1050,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 | @@ -1213,10 +1280,12 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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, @@ -1246,6 +1315,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(), @@ -1288,6 +1360,7 @@ private constructor( accountingSyncConfiguration, additionalEmails, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -1314,7 +1387,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). @@ -1332,6 +1406,17 @@ private constructor( */ fun autoCollection(): Optional = autoCollection.getOptional("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(): Optional = autoIssuance.getOptional("auto_issuance") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1516,9 +1601,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 | @@ -1624,6 +1709,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]. * @@ -1773,6 +1868,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() @@ -1795,6 +1891,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 @@ -1837,7 +1934,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)) @@ -1901,6 +1999,37 @@ 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?) + + /** Alias for calling [Builder.autoIssuance] with `autoIssuance.orElse(null)`. */ + fun autoIssuance(autoIssuance: Optional) = + autoIssuance(autoIssuance.getOrNull()) + + /** + * 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)) @@ -2230,6 +2359,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: + * ```java + * 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. @@ -2303,9 +2447,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 | @@ -2418,6 +2562,7 @@ private constructor( accountingSyncConfiguration, (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, + autoIssuance, billingAddress, currency, email, @@ -2446,6 +2591,7 @@ private constructor( accountingSyncConfiguration().ifPresent { it.validate() } additionalEmails() autoCollection() + autoIssuance() billingAddress().ifPresent { it.validate() } currency() email() @@ -2482,6 +2628,7 @@ private constructor( (accountingSyncConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (additionalEmails.asKnown().getOrNull()?.size ?: 0) + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (if (autoIssuance.asKnown().isPresent) 1 else 0) + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (email.asKnown().isPresent) 1 else 0) + @@ -2502,17 +2649,56 @@ 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 && + autoIssuance == other.autoIssuance && + 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, + autoIssuance, + 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() = - "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}" } /** @@ -2609,12 +2795,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 @@ -2766,7 +2950,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() @@ -2781,6 +2965,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, ) { @@ -2790,18 +2975,24 @@ private constructor( fun sphere(): Optional = Optional.ofNullable(sphere) + fun numeral(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -2809,6 +3000,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) } @@ -2832,6 +3024,10 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) { sphere.validate() } + + override fun visitNumeral(numeral: Numeral) { + numeral.validate() + } } ) validated = true @@ -2862,6 +3058,8 @@ private constructor( override fun visitSphere(sphere: NewSphereConfiguration) = sphere.validity() + override fun visitNumeral(numeral: Numeral) = numeral.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -2871,16 +3069,21 @@ 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 && + numeral == other.numeral } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalara, taxjar, sphere) /* spotless:on */ + 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") } @@ -2895,6 +3098,8 @@ private constructor( @JvmStatic fun ofSphere(sphere: NewSphereConfiguration) = TaxConfiguration(sphere = sphere) + + @JvmStatic fun ofNumeral(numeral: Numeral) = TaxConfiguration(numeral = numeral) } /** @@ -2909,6 +3114,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]. * @@ -2947,6 +3154,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) @@ -2964,11 +3176,222 @@ 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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: + * ```java + * 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: + * ```java + * .taxExempt() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (taxExempt.asKnown().isPresent) 1 else 0) + + 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 { @@ -2976,10 +3399,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-java-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt index 14feaac6..daae7597 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class DecrementLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -845,7 +846,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() @@ -965,7 +966,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() @@ -1067,12 +1068,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 @@ -1084,12 +1083,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt index 71d3d71c..976f8490 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class DimensionalPriceConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val dimensionalPriceGroupId: JsonField, @@ -224,12 +225,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt index 569b9b90..891786ef 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt @@ -24,6 +24,7 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -494,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 @@ -511,12 +510,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt index a0c99817..00a0c6b6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt @@ -24,7 +24,7 @@ import kotlin.jvm.optionals.getOrNull /** * 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 @@ -400,6 +400,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>, @@ -739,13 +740,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() = @@ -846,12 +860,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 @@ -863,10 +875,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt index 451164f1..a2380bf6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt @@ -203,10 +203,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt index 1e1f645b..d0f0111c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt @@ -338,6 +338,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, @@ -543,12 +544,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 @@ -650,12 +654,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 @@ -667,10 +669,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt index f3ceadd4..046eb809 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt @@ -124,10 +124,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt index 73f4c4aa..41813f6c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt @@ -139,10 +139,14 @@ private constructor( return true } - return /* spotless:off */ other is DimensionalPriceGroupListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is DimensionalPriceGroupListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "DimensionalPriceGroupListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt index bcb35fef..f30c5e04 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt @@ -214,10 +214,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt index 778cddb3..d4e11424 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt @@ -192,10 +192,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt index e34c4b41..e1aae7b9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt @@ -322,6 +322,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, @@ -519,12 +520,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 @@ -626,12 +630,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 @@ -643,10 +645,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-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt index e69db0a4..c4663fc3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class DimensionalPriceGroups +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -219,12 +220,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-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt index cc00f9b5..1d09bddd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt @@ -127,10 +127,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-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt index de4c2f58..a42caed7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class DiscountOverride +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonField, private val amountDiscount: JsonField, @@ -444,7 +445,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() @@ -457,12 +458,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-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt index 6e601e88..be5f47db 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt @@ -31,6 +31,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class EvaluatePriceGroup +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val groupingValues: JsonField>, @@ -359,10 +360,13 @@ private constructor( return true } - return /* spotless:off */ other is GroupingValue && string == other.string && number == other.number && bool == other.bool /* spotless:on */ + return other is GroupingValue && + string == other.string && + number == other.number && + bool == other.bool } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, number, bool) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(string, number, bool) override fun toString(): String = when { @@ -465,12 +469,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt index ec9abb5e..49494ba9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt @@ -219,10 +219,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt index e717cdd8..c45c26b3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt @@ -24,6 +24,7 @@ import kotlin.jvm.optionals.getOrNull * timeframe. */ class EventBackfillCloseResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, @@ -733,7 +734,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() @@ -746,12 +747,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt index 5ec44a67..fdba6025 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt @@ -45,8 +45,8 @@ import kotlin.jvm.optionals.getOrNull * 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. @@ -515,6 +515,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, @@ -982,12 +983,29 @@ 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 } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(timeframeEnd, timeframeStart, closeTime, customerId, deprecationFilter, externalCustomerId, replaceExistingEvents, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + timeframeEnd, + timeframeStart, + closeTime, + customerId, + deprecationFilter, + externalCustomerId, + replaceExistingEvents, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -1000,10 +1018,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt index f69ed127..092e6764 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt @@ -24,6 +24,7 @@ import kotlin.jvm.optionals.getOrNull * timeframe. */ class EventBackfillCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, @@ -733,7 +734,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() @@ -746,12 +747,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt index fd1c48f8..38798d5a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt @@ -180,10 +180,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt index 07770f58..6c8c8e4c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt @@ -24,6 +24,7 @@ import kotlin.jvm.optionals.getOrNull * timeframe. */ class EventBackfillFetchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, @@ -733,7 +734,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() @@ -746,12 +747,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt index 944841f1..ea5e9c16 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt @@ -123,10 +123,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt index 40c53ac9..c6a08af1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt @@ -137,10 +137,14 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is EventBackfillListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "EventBackfillListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt index 8c195679..19680390 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class EventBackfillListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -222,12 +223,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt index efcab38d..6a50942b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt @@ -216,10 +216,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt index a8f782f3..4cc96862 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt @@ -24,6 +24,7 @@ import kotlin.jvm.optionals.getOrNull * timeframe. */ class EventBackfillListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, @@ -733,7 +734,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() @@ -746,12 +747,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt index 83d71404..cb43976f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt @@ -224,10 +224,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-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt index 2a9e2cb8..a5e6e9ba 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt @@ -24,6 +24,7 @@ import kotlin.jvm.optionals.getOrNull * timeframe. */ class EventBackfillRevertResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val closeTime: JsonField, @@ -733,7 +734,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() @@ -746,12 +747,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-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt index 71000c9a..9e56e43f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt @@ -20,8 +20,8 @@ import kotlin.jvm.optionals.getOrNull * * 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 @@ -32,16 +32,16 @@ import kotlin.jvm.optionals.getOrNull * 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. */ @@ -247,10 +247,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-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt index 26d75833..93d124a0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt @@ -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, @@ -159,12 +160,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-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt index 5bf62698..e944a2c7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt @@ -80,7 +80,6 @@ import kotlin.jvm.optionals.getOrNull * ``` * * ## 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 @@ -110,7 +109,6 @@ import kotlin.jvm.optionals.getOrNull * 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. * @@ -164,7 +162,6 @@ import kotlin.jvm.optionals.getOrNull * 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. @@ -178,7 +175,6 @@ import kotlin.jvm.optionals.getOrNull * 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. @@ -197,7 +193,11 @@ import kotlin.jvm.optionals.getOrNull * { * "debug": { * "duplicate": [], - * "ingested": ["B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim"] + * "ingested": [ + * "B7E83HDMfJPAunXW", + * "SJs5DQJ3TnwSqEZE", + * "8SivfDsNKwCeAXim" + * ] * }, * "validation_failed": [] * } @@ -485,6 +485,7 @@ private constructor( .build() class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val events: JsonField>, private val additionalProperties: MutableMap, @@ -644,12 +645,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 @@ -657,6 +658,7 @@ private constructor( } class Event + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val eventName: JsonField, private val idempotencyKey: JsonField, @@ -1141,12 +1143,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 @@ -1158,12 +1158,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 @@ -1176,10 +1191,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-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt index cb494e82..e9c942c7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class EventIngestResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val validationFailed: JsonField>, private val debug: JsonField, @@ -226,6 +227,7 @@ private constructor( (debug.asKnown().getOrNull()?.validity() ?: 0) class ValidationFailed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val idempotencyKey: JsonField, private val validationErrors: JsonField>, @@ -438,12 +440,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 @@ -456,6 +461,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>, @@ -668,12 +674,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 @@ -686,12 +695,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-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt index 4b4c226f..3f722203 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt @@ -352,6 +352,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, @@ -623,12 +624,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 @@ -641,10 +646,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-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt index 08f1f9e2..168a79bf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class EventSearchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -177,6 +178,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, @@ -698,12 +700,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 @@ -715,12 +715,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 @@ -733,12 +750,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-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt index 4c800b3f..9d201bf0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt @@ -35,8 +35,8 @@ import kotlin.jvm.optionals.getOrNull * * 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 @@ -44,21 +44,21 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -443,6 +443,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, @@ -778,13 +779,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() = @@ -884,12 +898,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 @@ -901,10 +913,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-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt index 640c262d..532c6da5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt @@ -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, @@ -158,12 +159,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-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt index c7fdad16..cc8df6f6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt @@ -287,10 +287,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-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt index dc6a3602..d8cb1460 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt @@ -20,6 +20,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class EventVolumes +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -175,6 +176,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, @@ -403,12 +405,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 @@ -421,12 +427,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-java-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt index 5daf5bfc..b325ddb2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class ExpirationChangeLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -791,7 +792,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() @@ -911,7 +912,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() @@ -1013,12 +1014,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 @@ -1030,12 +1029,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-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt index b9550349..4a9a30e8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class FixedFeeQuantityScheduleEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endDate: JsonField, private val priceId: JsonField, @@ -268,12 +269,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-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt index 87fdf7dd..3fea24c3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt +++ b/orb-java-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, @@ -230,12 +231,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-java-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt index 003b2bda..98b22599 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt @@ -22,6 +22,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class IncrementLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -801,7 +802,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() @@ -921,7 +922,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() @@ -1023,12 +1024,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 @@ -1040,12 +1039,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-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index cc1daefd..453c1579 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -39,6 +39,7 @@ import kotlin.jvm.optionals.getOrNull * cancellation. */ class Invoice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amountDue: JsonField, @@ -369,9 +370,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 | @@ -1412,9 +1413,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 | @@ -2323,6 +2324,7 @@ private constructor( (if (willAutoIssue.asKnown().isPresent) 1 else 0) class AutoCollection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val enabled: JsonField, private val nextAttemptAt: JsonField, @@ -2647,12 +2649,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 @@ -2661,6 +2674,7 @@ private constructor( } class CreditNote + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val creditNoteNumber: JsonField, @@ -3030,12 +3044,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 @@ -3044,6 +3075,7 @@ private constructor( } class CustomerBalanceTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val action: JsonField, @@ -3597,6 +3629,8 @@ private constructor( @JvmField val EXTERNAL_PAYMENT = of("external_payment") + @JvmField val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) } @@ -3611,6 +3645,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, } /** @@ -3632,6 +3667,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. */ @@ -3656,6 +3692,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 } @@ -3679,6 +3716,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") } @@ -3726,7 +3764,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() @@ -3851,7 +3889,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() @@ -3864,12 +3902,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 @@ -4003,7 +4064,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() @@ -4012,6 +4073,7 @@ private constructor( } class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustedSubtotal: JsonField, @@ -4291,7 +4353,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). @@ -4995,27 +5057,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.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)) + /** 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)`. */ @@ -5026,14 +5079,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)`. @@ -5072,6 +5125,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)`. @@ -5086,6 +5143,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)`. @@ -5093,10 +5157,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)`. */ @@ -5131,12 +5191,14 @@ 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)) + + /** 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)) /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) @@ -5204,7 +5266,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)) /** @@ -5574,10 +5636,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 { @@ -5810,10 +5878,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 { @@ -5911,12 +5982,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 @@ -6018,12 +6136,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 @@ -6031,12 +6147,14 @@ private constructor( } class PaymentAttempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, private val createdAt: JsonField, private val paymentProvider: JsonField, private val paymentProviderId: JsonField, + private val receiptPdf: JsonField, private val succeeded: JsonField, private val additionalProperties: MutableMap, ) { @@ -6054,6 +6172,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(), @@ -6063,6 +6184,7 @@ private constructor( createdAt, paymentProvider, paymentProviderId, + receiptPdf, succeeded, mutableMapOf(), ) @@ -6109,6 +6231,15 @@ private constructor( fun paymentProviderId(): Optional = paymentProviderId.getOptional("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(): Optional = receiptPdf.getOptional("receipt_pdf") + /** * Whether the payment attempt succeeded. * @@ -6160,6 +6291,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]. * @@ -6191,6 +6331,7 @@ private constructor( * .createdAt() * .paymentProvider() * .paymentProviderId() + * .receiptPdf() * .succeeded() * ``` */ @@ -6205,6 +6346,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() @@ -6215,6 +6357,7 @@ private constructor( createdAt = paymentAttempt.createdAt paymentProvider = paymentAttempt.paymentProvider paymentProviderId = paymentAttempt.paymentProviderId + receiptPdf = paymentAttempt.receiptPdf succeeded = paymentAttempt.succeeded additionalProperties = paymentAttempt.additionalProperties.toMutableMap() } @@ -6297,6 +6440,24 @@ 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)) + + /** Alias for calling [Builder.receiptPdf] with `receiptPdf.orElse(null)`. */ + fun receiptPdf(receiptPdf: Optional) = receiptPdf(receiptPdf.getOrNull()) + + /** + * 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)) @@ -6340,6 +6501,7 @@ private constructor( * .createdAt() * .paymentProvider() * .paymentProviderId() + * .receiptPdf() * .succeeded() * ``` * @@ -6352,6 +6514,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("paymentProvider", paymentProvider), checkRequired("paymentProviderId", paymentProviderId), + checkRequired("receiptPdf", receiptPdf), checkRequired("succeeded", succeeded), additionalProperties.toMutableMap(), ) @@ -6369,6 +6532,7 @@ private constructor( createdAt() paymentProvider().ifPresent { it.validate() } paymentProviderId() + receiptPdf() succeeded() validated = true } @@ -6394,6 +6558,7 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (if (receiptPdf.asKnown().isPresent) 1 else 0) + (if (succeeded.asKnown().isPresent) 1 else 0) /** The payment provider that attempted to collect the payment. */ @@ -6513,7 +6678,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() @@ -6526,17 +6691,34 @@ 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 && + receiptPdf == other.receiptPdf && + 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, + receiptPdf, + succeeded, + additionalProperties, + ) + } 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 { @@ -6673,7 +6855,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() @@ -6686,12 +6868,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index a59c40c2..4d5c10da 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -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 @@ -73,6 +84,15 @@ private constructor( */ fun discount(): Optional = 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(): Optional = body.dueDate() + /** * The `external_customer_id` of the `Customer` to create this invoice for. One of `customer_id` * and `external_customer_id` are required. @@ -83,7 +103,8 @@ private constructor( fun externalCustomerId(): Optional = 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). @@ -101,9 +122,11 @@ private constructor( fun metadata(): Optional = 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). @@ -154,6 +177,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]. * @@ -371,6 +401,29 @@ 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) } + + /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ + fun dueDate(dueDate: Optional) = dueDate(dueDate.getOrNull()) + + /** + * 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. @@ -396,7 +449,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) } /** Alias for calling [Builder.memo] with `memo.orElse(null)`. */ @@ -430,9 +486,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) } @@ -617,12 +675,14 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val invoiceDate: JsonField, 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, @@ -648,6 +708,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(), @@ -665,6 +728,7 @@ private constructor( lineItems, customerId, discount, + dueDate, externalCustomerId, memo, metadata, @@ -713,6 +777,15 @@ private constructor( */ fun discount(): Optional = discount.getOptional("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(): Optional = dueDate.getOptional("due_date") + /** * The `external_customer_id` of the `Customer` to create this invoice for. One of * `customer_id` and `external_customer_id` are required. @@ -724,7 +797,8 @@ private constructor( externalCustomerId.getOptional("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). @@ -742,9 +816,11 @@ private constructor( fun metadata(): Optional = metadata.getOptional("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). @@ -801,6 +877,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]. * @@ -877,6 +960,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() @@ -891,6 +975,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 @@ -1053,6 +1138,30 @@ 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)) + + /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ + fun dueDate(dueDate: Optional) = dueDate(dueDate.getOrNull()) + + /** + * 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. @@ -1078,7 +1187,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)) /** Alias for calling [Builder.memo] with `memo.orElse(null)`. */ @@ -1113,10 +1225,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)) @@ -1196,6 +1309,7 @@ private constructor( checkRequired("lineItems", lineItems).map { it.toImmutable() }, customerId, discount, + dueDate, externalCustomerId, memo, metadata, @@ -1217,6 +1331,7 @@ private constructor( lineItems().forEach { it.validate() } customerId() discount().ifPresent { it.validate() } + dueDate().ifPresent { it.validate() } externalCustomerId() memo() metadata().ifPresent { it.validate() } @@ -1246,6 +1361,7 @@ private constructor( (lineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (customerId.asKnown().isPresent) 1 else 0) + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (dueDate.asKnown().getOrNull()?.validity() ?: 0) + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + (if (memo.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + @@ -1257,20 +1373,46 @@ 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 && + dueDate == other.dueDate && + 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, + dueDate, + externalCustomerId, + memo, + metadata, + netTerms, + willAutoIssue, + additionalProperties, + ) + } 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endDate: JsonField, private val itemId: JsonField, @@ -1348,6 +1490,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). */ @@ -1533,6 +1677,7 @@ private constructor( */ fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** @@ -1752,7 +1897,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() @@ -1765,12 +1910,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 @@ -1778,6 +1940,179 @@ 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(): Optional = Optional.ofNullable(date) + + fun dateTime(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic fun ofDate(date: LocalDate) = DueDate(date = date) + + @JvmStatic 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 @@ -1872,12 +2207,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 @@ -1889,10 +2222,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt index 3b839361..74a475a9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt @@ -176,10 +176,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt index 0d483cf4..0f5a3c34 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt @@ -191,10 +191,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index e7f672f9..ac71c808 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -32,6 +32,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class InvoiceFetchUpcomingResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amountDue: JsonField, @@ -362,9 +363,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 | @@ -1406,9 +1407,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 | @@ -2317,6 +2318,7 @@ private constructor( (if (willAutoIssue.asKnown().isPresent) 1 else 0) class AutoCollection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val enabled: JsonField, private val nextAttemptAt: JsonField, @@ -2641,12 +2643,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 @@ -2655,6 +2668,7 @@ private constructor( } class CreditNote + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val creditNoteNumber: JsonField, @@ -3024,12 +3038,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 @@ -3038,6 +3069,7 @@ private constructor( } class CustomerBalanceTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val action: JsonField, @@ -3591,6 +3623,8 @@ private constructor( @JvmField val EXTERNAL_PAYMENT = of("external_payment") + @JvmField val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) } @@ -3605,6 +3639,7 @@ private constructor( CREDIT_NOTE_VOIDED, OVERPAYMENT_REFUND, EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, } /** @@ -3626,6 +3661,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. */ @@ -3650,6 +3686,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 } @@ -3673,6 +3710,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") } @@ -3720,7 +3758,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() @@ -3845,7 +3883,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() @@ -3858,12 +3896,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 @@ -3997,7 +4058,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() @@ -4006,6 +4067,7 @@ private constructor( } class LineItem + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustedSubtotal: JsonField, @@ -4285,7 +4347,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). @@ -4989,27 +5051,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.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)) + /** 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)`. */ @@ -5020,14 +5073,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)`. @@ -5066,6 +5119,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)`. @@ -5080,6 +5137,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)`. @@ -5087,10 +5151,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)`. */ @@ -5125,12 +5185,14 @@ 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)) + + /** 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)) /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) @@ -5198,7 +5260,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)) /** @@ -5568,10 +5630,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 { @@ -5804,10 +5872,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 { @@ -5905,12 +5976,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 @@ -6012,12 +6130,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 @@ -6025,12 +6141,14 @@ private constructor( } class PaymentAttempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, private val createdAt: JsonField, private val paymentProvider: JsonField, private val paymentProviderId: JsonField, + private val receiptPdf: JsonField, private val succeeded: JsonField, private val additionalProperties: MutableMap, ) { @@ -6048,6 +6166,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(), @@ -6057,6 +6178,7 @@ private constructor( createdAt, paymentProvider, paymentProviderId, + receiptPdf, succeeded, mutableMapOf(), ) @@ -6103,6 +6225,15 @@ private constructor( fun paymentProviderId(): Optional = paymentProviderId.getOptional("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(): Optional = receiptPdf.getOptional("receipt_pdf") + /** * Whether the payment attempt succeeded. * @@ -6154,6 +6285,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]. * @@ -6185,6 +6325,7 @@ private constructor( * .createdAt() * .paymentProvider() * .paymentProviderId() + * .receiptPdf() * .succeeded() * ``` */ @@ -6199,6 +6340,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() @@ -6209,6 +6351,7 @@ private constructor( createdAt = paymentAttempt.createdAt paymentProvider = paymentAttempt.paymentProvider paymentProviderId = paymentAttempt.paymentProviderId + receiptPdf = paymentAttempt.receiptPdf succeeded = paymentAttempt.succeeded additionalProperties = paymentAttempt.additionalProperties.toMutableMap() } @@ -6291,6 +6434,24 @@ 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)) + + /** Alias for calling [Builder.receiptPdf] with `receiptPdf.orElse(null)`. */ + fun receiptPdf(receiptPdf: Optional) = receiptPdf(receiptPdf.getOrNull()) + + /** + * 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)) @@ -6334,6 +6495,7 @@ private constructor( * .createdAt() * .paymentProvider() * .paymentProviderId() + * .receiptPdf() * .succeeded() * ``` * @@ -6346,6 +6508,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("paymentProvider", paymentProvider), checkRequired("paymentProviderId", paymentProviderId), + checkRequired("receiptPdf", receiptPdf), checkRequired("succeeded", succeeded), additionalProperties.toMutableMap(), ) @@ -6363,6 +6526,7 @@ private constructor( createdAt() paymentProvider().ifPresent { it.validate() } paymentProviderId() + receiptPdf() succeeded() validated = true } @@ -6388,6 +6552,7 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (if (receiptPdf.asKnown().isPresent) 1 else 0) + (if (succeeded.asKnown().isPresent) 1 else 0) /** The payment provider that attempted to collect the payment. */ @@ -6507,7 +6672,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() @@ -6520,17 +6685,34 @@ 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 && + receiptPdf == other.receiptPdf && + 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, + receiptPdf, + succeeded, + additionalProperties, + ) + } 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 { @@ -6667,7 +6849,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() @@ -6680,12 +6862,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt index 51b3e671..1abaccac 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt @@ -263,6 +263,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, @@ -404,12 +405,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 @@ -422,10 +423,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt index bdf19bc7..965cdd22 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt @@ -113,10 +113,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt index e457db5e..a5959ef5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt @@ -398,6 +398,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, @@ -738,12 +739,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 @@ -756,10 +772,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index f226b181..7a1fbe83 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -31,6 +31,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class InvoiceLineItemCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustedSubtotal: JsonField, @@ -300,7 +301,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). @@ -986,27 +987,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.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)) + /** 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)) @@ -1014,13 +1006,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)`. @@ -1054,6 +1046,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)`. @@ -1068,16 +1064,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)) @@ -1108,12 +1107,14 @@ 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)) + + /** 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)) /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) @@ -1176,7 +1177,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)) /** @@ -1541,10 +1542,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 { @@ -1773,10 +1780,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 { @@ -1874,12 +1884,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt index 5c65a905..8ddf5ffb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt index 2cab73fd..986bab96 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt @@ -135,10 +135,14 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is InvoiceListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "InvoiceListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt index 1709b9e2..2a11d096 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class InvoiceListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -217,12 +218,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt index f4c69d4c..ea9bc94a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt @@ -598,7 +598,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() @@ -740,7 +740,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() @@ -753,10 +753,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt index 05013332..6ccfcd73 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt @@ -22,8 +22,8 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * 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( @@ -332,6 +332,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, @@ -565,12 +566,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 @@ -583,10 +588,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-java-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt index 32a64ad3..feb00758 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt @@ -217,10 +217,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt index 5b1d4ea4..fb6ef310 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt +++ b/orb-java-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, @@ -155,12 +156,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt index ffa9bd2a..c9a0776e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt @@ -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 import java.util.Optional @@ -38,6 +51,15 @@ private constructor( fun invoiceId(): Optional = Optional.ofNullable(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(): Optional = 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 @@ -48,6 +70,25 @@ private constructor( */ fun metadata(): Optional = 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(): Optional = 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]. * @@ -55,6 +96,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. */ @@ -99,10 +147,35 @@ 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) } + + /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ + fun dueDate(dueDate: Optional) = dueDate(dueDate.getOrNull()) + + /** + * 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 @@ -122,6 +195,33 @@ 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?) + + /** Alias for calling [Builder.netTerms] with `netTerms.orElse(null)`. */ + fun netTerms(netTerms: Optional) = netTerms(netTerms.getOrNull()) + + /** + * 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) } @@ -266,17 +366,33 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = dueDate.getOptional("due_date") /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -288,6 +404,25 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("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(): Optional = netTerms.getOptional("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]. * @@ -295,6 +430,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) @@ -316,15 +458,43 @@ 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() @JvmSynthetic 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)) + + /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ + fun dueDate(dueDate: Optional) = dueDate(dueDate.getOrNull()) + + /** + * 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 @@ -344,6 +514,34 @@ 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?) + + /** Alias for calling [Builder.netTerms] with `netTerms.orElse(null)`. */ + fun netTerms(netTerms: Optional) = netTerms(netTerms.getOrNull()) + + /** + * 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) @@ -368,7 +566,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 @@ -378,7 +577,9 @@ private constructor( return@apply } + dueDate().ifPresent { it.validate() } metadata().ifPresent { it.validate() } + netTerms() validated = true } @@ -397,24 +598,204 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + internal fun validity(): Int = + (dueDate.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (netTerms.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Body && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is Body && + dueDate == other.dueDate && + metadata == other.metadata && + netTerms == other.netTerms && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ + 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(): Optional = Optional.ofNullable(date) + + fun dateTime(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic fun ofDate(date: LocalDate) = DueDate(date = date) + + @JvmStatic 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") + } + } + } } /** @@ -511,12 +892,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 @@ -528,10 +907,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-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt index 18ffb169..b4ab0dda 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt @@ -12,7 +12,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * 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 @@ -225,10 +225,15 @@ private constructor( return true } - return /* spotless:off */ other is InvoiceVoidInvoiceParams && invoiceId == other.invoiceId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return other is InvoiceVoidInvoiceParams && + 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() = "InvoiceVoidInvoiceParams{invoiceId=$invoiceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt index 0db42844..47f387c3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -18,6 +18,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects +import java.util.Optional import kotlin.jvm.optionals.getOrNull /** @@ -26,12 +27,14 @@ import kotlin.jvm.optionals.getOrNull * and tax calculation purposes. */ class Item +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val createdAt: JsonField, private val externalConnections: JsonField>, private val metadata: JsonField, private val name: JsonField, + private val archivedAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -46,21 +49,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 +91,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(): Optional = archivedAt.getOptional("archived_at") + /** * Returns the raw JSON value of [id]. * @@ -123,6 +146,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 +192,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() @JvmSynthetic @@ -169,9 +202,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)) /** @@ -182,6 +217,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)) /** @@ -193,6 +229,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)) @@ -235,6 +275,7 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** The name of the item. */ fun name(name: String) = name(JsonField.of(name)) /** @@ -245,6 +286,23 @@ 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)) + + /** Alias for calling [Builder.archivedAt] with `archivedAt.orElse(null)`. */ + fun archivedAt(archivedAt: Optional) = archivedAt(archivedAt.getOrNull()) + + /** + * 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) @@ -287,6 +345,7 @@ private constructor( checkRequired("externalConnections", externalConnections).map { it.toImmutable() }, checkRequired("metadata", metadata), checkRequired("name", name), + archivedAt, additionalProperties.toMutableMap(), ) } @@ -303,6 +362,7 @@ private constructor( externalConnections().forEach { it.validate() } metadata().validate() name() + archivedAt() validated = true } @@ -325,9 +385,15 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (externalConnections.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + (if (archivedAt.asKnown().isPresent) 1 else 0) + /** + * 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( private val externalConnectionName: JsonField, private val externalEntityId: JsonField, @@ -345,6 +411,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). */ @@ -352,6 +420,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). */ @@ -417,6 +487,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)) @@ -432,6 +503,7 @@ private constructor( this.externalConnectionName = externalConnectionName } + /** The identifier of this item in the external system. */ fun externalEntityId(externalEntityId: String) = externalEntityId(JsonField.of(externalEntityId)) @@ -517,6 +589,7 @@ private constructor( (externalConnectionName.asKnown().getOrNull()?.validity() ?: 0) + (if (externalEntityId.asKnown().isPresent) 1 else 0) + /** The name of the external system this item is connected to. */ class ExternalConnectionName @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -547,6 +620,8 @@ private constructor( @JvmField val ANROK = of("anrok") + @JvmField val NUMERAL = of("numeral") + @JvmStatic fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -559,6 +634,7 @@ private constructor( TAXJAR, AVALARA, ANROK, + NUMERAL, } /** @@ -580,6 +656,7 @@ private constructor( TAXJAR, AVALARA, ANROK, + NUMERAL, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -603,6 +680,7 @@ private constructor( TAXJAR -> Value.TAXJAR AVALARA -> Value.AVALARA ANROK -> Value.ANROK + NUMERAL -> Value.NUMERAL else -> Value._UNKNOWN } @@ -624,6 +702,7 @@ private constructor( TAXJAR -> Known.TAXJAR AVALARA -> Known.AVALARA ANROK -> Known.ANROK + NUMERAL -> Known.NUMERAL else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } @@ -671,7 +750,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() @@ -684,12 +763,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 @@ -791,12 +873,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 @@ -808,15 +888,30 @@ 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 && + archivedAt == other.archivedAt && + 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, + 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-java-core/src/main/kotlin/com/withorb/api/models/ItemArchiveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemArchiveParams.kt index b5f68505..1c9a8167 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemArchiveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemArchiveParams.kt @@ -214,10 +214,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-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt index 32fb9ce2..fd299739 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt @@ -278,6 +278,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, @@ -465,12 +466,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 @@ -572,12 +574,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 @@ -589,10 +589,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-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt index b67ff20b..6aedc531 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt @@ -176,10 +176,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-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt index 6dc4e27e..99a1df07 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt index d594a9a9..e7180b1c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt @@ -134,10 +134,14 @@ private constructor( return true } - return /* spotless:off */ other is ItemListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is ItemListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "ItemListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt index bc10c10b..458052ff 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class ItemListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -216,12 +217,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-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt index c3b13ef5..c0386caa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt @@ -204,10 +204,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-java-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt index 60f3c602..d25ebf08 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt @@ -15,7 +15,9 @@ 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( private val id: JsonField, private val name: JsonField, @@ -29,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 +100,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 +111,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The name of the item. */ fun name(name: String) = name(JsonField.of(name)) /** @@ -188,12 +196,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-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt index 2692e27e..a7e8634c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt @@ -339,6 +339,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, @@ -576,12 +577,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 @@ -589,7 +594,12 @@ 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( private val externalConnectionName: JsonField, private val externalEntityId: JsonField, @@ -607,6 +617,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). */ @@ -614,6 +626,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). */ @@ -679,6 +693,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)) @@ -694,6 +709,7 @@ private constructor( this.externalConnectionName = externalConnectionName } + /** The identifier of this item in the external system. */ fun externalEntityId(externalEntityId: String) = externalEntityId(JsonField.of(externalEntityId)) @@ -779,6 +795,7 @@ private constructor( (externalConnectionName.asKnown().getOrNull()?.validity() ?: 0) + (if (externalEntityId.asKnown().isPresent) 1 else 0) + /** The name of the external system this item is connected to. */ class ExternalConnectionName @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -809,6 +826,8 @@ private constructor( @JvmField val ANROK = of("anrok") + @JvmField val NUMERAL = of("numeral") + @JvmStatic fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -821,6 +840,7 @@ private constructor( TAXJAR, AVALARA, ANROK, + NUMERAL, } /** @@ -842,6 +862,7 @@ private constructor( TAXJAR, AVALARA, ANROK, + NUMERAL, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -865,6 +886,7 @@ private constructor( TAXJAR -> Value.TAXJAR AVALARA -> Value.AVALARA ANROK -> Value.ANROK + NUMERAL -> Value.NUMERAL else -> Value._UNKNOWN } @@ -886,6 +908,7 @@ private constructor( TAXJAR -> Known.TAXJAR AVALARA -> Known.AVALARA ANROK -> Known.ANROK + NUMERAL -> Known.NUMERAL else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } @@ -933,7 +956,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() @@ -946,12 +969,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 @@ -1053,12 +1079,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 @@ -1070,10 +1094,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-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt index 9caeb502..424c1b78 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt @@ -18,7 +18,9 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Configuration for matrix pricing */ class MatrixConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val defaultUnitAmount: JsonField, private val dimensions: JsonField>, @@ -56,7 +58,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). @@ -175,7 +177,7 @@ private constructor( } } - /** Matrix values for specified matrix grouping keys */ + /** Matrix values configuration */ fun matrixValues(matrixValues: List) = matrixValues(JsonField.of(matrixValues)) /** @@ -280,12 +282,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-java-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt index 23fc54cc..8f496f4f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class MatrixSubLineItem +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val grouping: JsonField, @@ -26,6 +27,7 @@ private constructor( private val name: JsonField, private val quantity: JsonField, private val type: JsonField, + private val scaledQuantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -41,7 +43,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. @@ -81,6 +86,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(): Optional = scaledQuantity.getOptional("scaled_quantity") + /** * Returns the raw JSON value of [amount]. * @@ -127,6 +140,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) @@ -166,6 +188,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() @JvmSynthetic @@ -176,6 +199,7 @@ private constructor( name = matrixSubLineItem.name quantity = matrixSubLineItem.quantity type = matrixSubLineItem.type + scaledQuantity = matrixSubLineItem.scaledQuantity additionalProperties = matrixSubLineItem.additionalProperties.toMutableMap() } @@ -248,6 +272,32 @@ 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?) + + /** Alias for calling [Builder.scaledQuantity] with `scaledQuantity.orElse(null)`. */ + fun scaledQuantity(scaledQuantity: Optional) = + scaledQuantity(scaledQuantity.getOrNull()) + + /** + * 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) @@ -292,6 +342,7 @@ private constructor( checkRequired("name", name), checkRequired("quantity", quantity), checkRequired("type", type), + scaledQuantity, additionalProperties.toMutableMap(), ) } @@ -309,6 +360,7 @@ private constructor( name() quantity() type().validate() + scaledQuantity() validated = true } @@ -332,7 +384,8 @@ private constructor( (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (scaledQuantity.asKnown().isPresent) 1 else 0) class Type @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -444,7 +497,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() @@ -457,15 +510,32 @@ 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 && + scaledQuantity == other.scaledQuantity && + 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, + 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-java-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt index 5a16ab75..d9924e4b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt @@ -18,7 +18,9 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Configuration for a single matrix value */ class MatrixValue +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val unitAmount: JsonField, @@ -36,9 +38,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). @@ -109,11 +109,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)) @@ -227,12 +223,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-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt index 6a844c25..1e291602 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt @@ -18,9 +18,11 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Configuration for matrix pricing with usage allocation */ class MatrixWithAllocationConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val allocation: JsonField, + private val allocation: JsonField, private val defaultUnitAmount: JsonField, private val dimensions: JsonField>, private val matrixValues: JsonField>, @@ -31,7 +33,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(), @@ -44,12 +46,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 @@ -68,7 +70,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). @@ -80,7 +82,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]. @@ -141,7 +143,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 @@ -156,17 +158,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) = @@ -209,7 +211,7 @@ private constructor( } } - /** Matrix values for specified matrix grouping keys */ + /** Matrix values configuration */ fun matrixValues(matrixValues: List) = matrixValues(JsonField.of(matrixValues)) /** @@ -313,17 +315,253 @@ private constructor( (dimensions.asKnown().getOrNull()?.sumOf { (if (it == null) 0 else 1).toInt() } ?: 0) + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Configuration for a single matrix value */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { (if (it == null) 0 else 1).toInt() } + ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 } - 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-java-core/src/main/kotlin/com/withorb/api/models/Maximum.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Maximum.kt index 1da03023..c03510d2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Maximum.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Maximum.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class Maximum +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIds: JsonField>, private val filters: JsonField>, @@ -289,12 +290,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-java-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt index 854c4cd0..93c1d426 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class MaximumInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIntervalIds: JsonField>, private val endDate: JsonField, @@ -371,12 +372,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-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt index 01265434..f1ce80bf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt @@ -378,6 +378,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, @@ -686,12 +687,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 @@ -793,12 +800,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 @@ -810,10 +815,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-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt index 770ee4bd..455b267e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt @@ -179,10 +179,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-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt index 55a2e386..28ce8ed9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt @@ -123,10 +123,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-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt index d1c38139..c8e820fc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt @@ -136,10 +136,14 @@ private constructor( return true } - return /* spotless:off */ other is MetricListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is MetricListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "MetricListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt index 819c853f..61126ef4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class MetricListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -219,12 +220,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-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt index ee91e370..1b8badee 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt @@ -274,10 +274,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-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt index a67dfd41..7f158347 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt @@ -262,6 +262,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, @@ -400,12 +401,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 @@ -507,12 +508,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 @@ -524,10 +523,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-java-core/src/main/kotlin/com/withorb/api/models/Minimum.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Minimum.kt index 0f0d1843..a35f7491 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Minimum.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Minimum.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class Minimum +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIds: JsonField>, private val filters: JsonField>, @@ -289,12 +290,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-java-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt index 19f0603c..65f8e9ad 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class MinimumInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIntervalIds: JsonField>, private val endDate: JsonField, @@ -371,12 +372,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-java-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt index 7ceb9fd9..b71ed517 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class MonetaryAmountDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -117,7 +118,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 @@ -395,8 +396,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)) @@ -662,7 +663,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 +676,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-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt index 74e8ff45..ccc6fbbf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class MonetaryMaximumAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -108,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 @@ -375,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)) @@ -659,7 +660,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 +673,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-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt index 5411af3b..3530f7b3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class MonetaryMinimumAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -111,7 +112,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 @@ -396,8 +397,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)) @@ -695,7 +696,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 +709,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-java-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt index 88586711..bd86ad2d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class MonetaryPercentageDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -108,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 @@ -380,8 +381,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)) @@ -665,7 +666,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 +679,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-java-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt index d6010e91..7601f319 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class MonetaryUsageDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -108,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 @@ -378,8 +379,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)) @@ -662,7 +663,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 +676,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-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt index 6da0977e..c89ec754 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt @@ -32,6 +32,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class MutatedSubscription +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val activePlanPhaseOrder: JsonField, @@ -1695,10 +1696,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 { @@ -1889,12 +1893,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 @@ -2023,7 +2025,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() @@ -2036,12 +2038,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-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt index 5c3d07d7..7f851e29 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewAccountingSyncConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountingProviders: JsonField>, private val excluded: JsonField, @@ -221,12 +222,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-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt index d3f66524..1931b4c0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val cadence: JsonField, @@ -475,7 +476,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() @@ -488,12 +489,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-java-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt index e5839366..6b681bfb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewAmountDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val amountDiscount: JsonField, @@ -666,7 +667,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() @@ -785,7 +786,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() @@ -930,7 +931,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() @@ -943,12 +944,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-java-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt index 15f4672c..7b454773 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewAvalaraTaxConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val taxExempt: JsonField, private val taxProvider: JsonField, @@ -353,7 +354,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() @@ -366,12 +367,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-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt index a9ae17c2..44213f2b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt @@ -18,6 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class NewBillingCycleConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val duration: JsonField, private val durationUnit: JsonField, @@ -319,7 +320,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() @@ -332,12 +333,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-java-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt index 7cda379b..d0716c57 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewDimensionalPriceConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val dimensionalPriceGroupId: JsonField, @@ -295,12 +296,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt deleted file mode 100644 index 5fcc7a0a..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBpsPrice.kt +++ /dev/null @@ -1,1543 +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.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 -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = billableMetricId.getOptional("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Optional = billedInAdvance.getOptional("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(): Optional = - billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = - conversionRateConfig.getOptional("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(): Optional = - dimensionalPriceConfiguration.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = - fixedPriceQuantity.getOptional("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(): Optional = - invoiceGroupingKey.getOptional("invoice_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(): Optional = - invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: - * ```java - * .bpsConfig() - * .cadence() - * .currency() - * .itemId() - * .modelType() - * .name() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.billableMetricId] with `billableMetricId.orElse(null)`. */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. 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?) - - /** Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. 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)) - - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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?) - - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. 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: - * ```java - * 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: - * ```java - * 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)) - - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. 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)) - - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. 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?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * 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: - * ```java - * .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().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - 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 { - - @JvmField val BPS = of("bps") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - 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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is 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 */ - } - - /* 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 */ - - 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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt index 50dd3de4..1aaa47b7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, @@ -117,6 +108,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). */ @@ -147,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). */ @@ -486,6 +481,7 @@ private constructor( additionalProperties = newFloatingBulkPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk pricing */ fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) /** @@ -530,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)) /** @@ -1114,7 +1111,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() @@ -1122,6 +1119,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1234,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() @@ -1242,184 +1240,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1514,12 +1334,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 @@ -1531,12 +1349,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt index f4a40ed2..2f1da638 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingBulkWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, @@ -117,6 +109,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). */ @@ -148,6 +142,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). */ @@ -494,6 +490,7 @@ private constructor( newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_proration pricing */ fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) @@ -542,6 +539,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -985,16 +983,43 @@ private constructor( (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1002,6 +1027,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1009,13 +1039,41 @@ private constructor( /** A builder for [BulkWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic 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) @@ -1039,9 +1097,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: + * ```java + * .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 @@ -1051,6 +1119,7 @@ private constructor( return@apply } + tiers().forEach { it.validate() } validated = true } @@ -1070,24 +1139,248 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = tierLowerBound.getOptional("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: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.tierLowerBound] with `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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. */ @@ -1231,7 +1524,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() @@ -1239,6 +1532,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1351,7 +1645,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() @@ -1359,184 +1653,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1631,12 +1747,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 @@ -1648,12 +1762,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt index 93876074..10c750cc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingCumulativeGroupedBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, @@ -125,6 +117,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). */ @@ -148,6 +142,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). */ @@ -508,6 +504,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)) @@ -544,6 +541,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1128,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() @@ -1136,16 +1134,66 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1154,6 +1202,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1161,14 +1215,58 @@ 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() @JvmSynthetic 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) @@ -1192,9 +1290,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: + * ```java + * .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 @@ -1204,6 +1314,8 @@ private constructor( return@apply } + dimensionValues().forEach { it.validate() } + group() validated = true } @@ -1223,26 +1335,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown().isPresent) 1 else 0) + + /** 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: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1355,7 +1738,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,184 +1746,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1635,12 +1840,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 @@ -1652,12 +1855,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt index ba51697f..a508400b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingGroupedAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -133,6 +124,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). */ @@ -148,6 +141,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 +511,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_allocation pricing */ fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) @@ -542,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)) /** @@ -1126,7 +1123,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() @@ -1134,16 +1131,90 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1151,6 +1222,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1158,13 +1236,60 @@ 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() @JvmSynthetic 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) @@ -1188,9 +1313,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: + * ```java + * .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 @@ -1200,6 +1339,9 @@ private constructor( return@apply } + allocation() + groupingKey() + overageUnitRate() validated = true } @@ -1219,26 +1361,33 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1351,7 +1500,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() @@ -1359,184 +1508,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1631,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 @@ -1648,12 +1617,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt index 70f9d3d1..531f6ca5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingGroupedTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -133,6 +125,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). */ @@ -148,6 +142,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). */ @@ -519,6 +515,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)) @@ -544,6 +541,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1128,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() @@ -1136,16 +1134,86 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1154,6 +1222,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1161,14 +1236,77 @@ 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() @JvmSynthetic 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) @@ -1192,9 +1330,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: + * ```java + * .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 @@ -1204,6 +1356,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1223,26 +1378,249 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * 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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1355,7 +1733,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,184 +1741,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1635,12 +1835,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 @@ -1652,12 +1850,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt index 966ac006..c0ee1628 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingGroupedTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -133,6 +125,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). */ @@ -148,6 +142,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). */ @@ -512,6 +508,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for grouped_tiered pricing */ fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = groupedTieredConfig(JsonField.of(groupedTieredConfig)) @@ -537,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)) /** @@ -1121,7 +1119,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() @@ -1129,35 +1127,137 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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: + * ```java + * .groupingKey() + * .tiers() + * ``` + */ @JvmStatic 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() @JvmSynthetic 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) @@ -1181,9 +1281,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: + * ```java + * .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 @@ -1193,6 +1305,8 @@ private constructor( return@apply } + groupingKey() + tiers().forEach { it.validate() } validated = true } @@ -1212,25 +1326,250 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1343,7 +1682,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() @@ -1351,184 +1690,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1623,12 +1784,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 @@ -1640,12 +1799,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt index f7c622eb..fae2b366 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingGroupedWithMeteredMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -134,6 +126,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). */ @@ -149,6 +143,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). */ @@ -521,6 +517,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)) @@ -547,6 +544,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1131,7 +1129,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() @@ -1139,16 +1137,163 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1157,6 +1302,16 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1164,15 +1319,140 @@ 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() @JvmSynthetic 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) @@ -1196,9 +1476,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: + * ```java + * .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 @@ -1208,6 +1508,12 @@ private constructor( return@apply } + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } validated = true } @@ -1227,26 +1533,488 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * 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: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + 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 } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1359,7 +2127,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() @@ -1367,184 +2135,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1639,12 +2229,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 @@ -1656,12 +2244,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt index b15a751e..d22b0af4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingGroupedWithProratedMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -134,6 +125,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). */ @@ -149,6 +142,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). */ @@ -521,6 +516,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)) @@ -547,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)) /** @@ -1131,7 +1128,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() @@ -1139,16 +1136,83 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1157,6 +1221,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1164,15 +1235,59 @@ 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() @JvmSynthetic 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) @@ -1196,9 +1311,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: + * ```java + * .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 @@ -1208,6 +1337,9 @@ private constructor( return@apply } + groupingKey() + minimum() + unitRate() validated = true } @@ -1227,26 +1359,33 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1359,7 +1498,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() @@ -1367,184 +1506,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1639,12 +1600,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 @@ -1656,12 +1615,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt index 205fa49f..f0792977 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingMatrixPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,12 +132,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). */ @@ -519,6 +514,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix pricing */ fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) /** @@ -532,6 +528,7 @@ private constructor( this.matrixConfig = matrixConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1116,7 +1113,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() @@ -1124,6 +1121,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1236,7 +1234,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() @@ -1244,184 +1242,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1516,12 +1336,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 @@ -1533,12 +1351,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt index ff2a2479..0038970c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingMatrixWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,6 +132,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). */ @@ -148,6 +141,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). */ @@ -530,6 +525,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)) @@ -544,6 +540,7 @@ private constructor( matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1128,7 +1125,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() @@ -1136,6 +1133,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1248,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() @@ -1256,184 +1254,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1528,12 +1348,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 @@ -1545,12 +1363,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt index ac823840..027156aa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingMatrixWithDisplayNamePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,6 +133,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). */ @@ -148,6 +142,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). */ @@ -530,6 +526,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)) @@ -544,6 +541,7 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1128,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() @@ -1136,16 +1134,66 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1154,6 +1202,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1161,14 +1215,56 @@ 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() @JvmSynthetic 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) @@ -1192,9 +1288,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: + * ```java + * .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 @@ -1204,6 +1312,8 @@ private constructor( return@apply } + dimension() + unitAmounts().forEach { it.validate() } validated = true } @@ -1223,26 +1333,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1355,7 +1736,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,184 +1744,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1635,12 +1838,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 @@ -1652,12 +1853,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt index 97119532..212d370c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingMaxGroupTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,6 +133,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). */ @@ -148,6 +142,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). */ @@ -530,6 +526,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)) @@ -544,6 +541,7 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1128,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() @@ -1136,16 +1134,85 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1154,6 +1221,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1161,14 +1235,74 @@ 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() @JvmSynthetic 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) @@ -1192,9 +1326,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: + * ```java + * .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 @@ -1204,6 +1352,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1223,26 +1374,254 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1355,7 +1734,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,184 +1742,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1635,12 +1836,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 @@ -1652,12 +1851,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt similarity index 80% rename from orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt rename to orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt index b7db8c68..55b8be60 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkBpsPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.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 @@ -29,12 +19,13 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class NewFloatingBulkBpsPrice +class NewFloatingMinimumCompositePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkBpsConfig: JsonField, 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, @@ -53,12 +44,12 @@ private constructor( @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("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonField = JsonMissing.of(), @@ -96,10 +87,10 @@ private constructor( invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( - bulkBpsConfig, cadence, currency, itemId, + minimumConfig, modelType, name, billableMetricId, @@ -116,12 +107,6 @@ private constructor( 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. * @@ -147,6 +132,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). */ @@ -258,15 +253,6 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("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]. * @@ -288,6 +274,15 @@ private constructor( */ @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]. * @@ -424,14 +419,15 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewFloatingBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of + * [NewFloatingMinimumCompositePrice]. * * The following fields are required: * ```java - * .bulkBpsConfig() * .cadence() * .currency() * .itemId() + * .minimumConfig() * .modelType() * .name() * ``` @@ -439,13 +435,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingBulkBpsPrice]. */ + /** A builder for [NewFloatingMinimumCompositePrice]. */ 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 minimumConfig: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -465,39 +461,31 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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 - } + 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)) @@ -532,6 +520,21 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** 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 + } + + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -876,28 +879,28 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingBulkBpsPrice]. + * Returns an immutable instance of [NewFloatingMinimumCompositePrice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .bulkBpsConfig() * .cadence() * .currency() * .itemId() + * .minimumConfig() * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingBulkBpsPrice = - NewFloatingBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), + fun build(): NewFloatingMinimumCompositePrice = + NewFloatingMinimumCompositePrice( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), checkRequired("modelType", modelType), checkRequired("name", name), billableMetricId, @@ -917,15 +920,15 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingBulkBpsPrice = apply { + fun validate(): NewFloatingMinimumCompositePrice = apply { if (validated) { return@apply } - bulkBpsConfig().validate() cadence().validate() currency() itemId() + minimumConfig().validate() modelType().validate() name() billableMetricId() @@ -957,10 +960,10 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (minimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (modelType.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -1116,7 +1119,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() @@ -1124,6 +1127,215 @@ private constructor( override fun toString() = value.toString() } + /** 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(): Optional = prorated.getOptional("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: + * ```java + * .minimumAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (prorated.asKnown().isPresent) 1 else 0) + + 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}" + } + + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1138,14 +1350,14 @@ private constructor( companion object { - @JvmField val BULK_BPS = of("bulk_bps") + @JvmField val MINIMUM = of("minimum") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - BULK_BPS + MINIMUM } /** @@ -1158,7 +1370,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BULK_BPS, + MINIMUM, /** * An enum member indicating that [ModelType] was instantiated with an unknown value. */ @@ -1174,7 +1386,7 @@ private constructor( */ fun value(): Value = when (this) { - BULK_BPS -> Value.BULK_BPS + MINIMUM -> Value.MINIMUM else -> Value._UNKNOWN } @@ -1188,7 +1400,7 @@ private constructor( */ fun known(): Known = when (this) { - BULK_BPS -> Known.BULK_BPS + MINIMUM -> Known.MINIMUM else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -1236,7 +1448,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() @@ -1244,184 +1456,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1516,12 +1550,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 @@ -1533,15 +1565,52 @@ 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 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 } - /* 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( + 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() = - "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}" + "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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt index 3e817a7f..fb230bd5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,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). */ @@ -155,6 +148,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 +514,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 +537,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package pricing */ fun packageConfig(packageConfig: PackageConfig) = packageConfig(JsonField.of(packageConfig)) /** @@ -1116,7 +1113,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() @@ -1124,6 +1121,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1236,7 +1234,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() @@ -1244,184 +1242,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1516,12 +1336,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 @@ -1533,12 +1351,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt index 2f9a8457..d9cd0751 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingPackageWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,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). */ @@ -155,6 +148,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). */ @@ -530,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)) /** @@ -552,6 +548,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)) @@ -1128,7 +1125,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() @@ -1136,6 +1133,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1248,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() @@ -1256,16 +1254,90 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1274,6 +1346,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1281,14 +1360,60 @@ 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() @JvmSynthetic 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) @@ -1312,9 +1437,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: + * ```java + * .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 @@ -1324,6 +1463,9 @@ private constructor( return@apply } + allocation() + packageAmount() + packageSize() validated = true } @@ -1343,202 +1485,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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") - } - } - } + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" } /** @@ -1635,12 +1605,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 @@ -1652,12 +1620,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt index 4e45fb79..2edc9ff1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingScalableMatrixWithTieredPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -143,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). */ @@ -157,6 +151,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). */ @@ -539,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)) /** @@ -561,6 +558,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ fun scalableMatrixWithTieredPricingConfig( scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig ) = @@ -1146,7 +1144,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() @@ -1154,6 +1152,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1267,7 +1266,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,16 +1274,110 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = secondDimension.getOptional("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) @@ -1293,6 +1386,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1300,16 +1400,115 @@ 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() @JvmSynthetic 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)) + + /** Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * 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) @@ -1333,9 +1532,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: + * ```java + * .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 @@ -1345,6 +1561,10 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() validated = true } @@ -1364,202 +1584,538 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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(): Optional = + secondDimensionValue.getOptional("second_dimension_value") - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" - } + /** + * 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 - /** 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, - ) { + /** + * 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 - fun unit(): Optional = Optional.ofNullable(unit) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tiered(): Optional = Optional.ofNullable(tiered) + @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: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { - fun isTiered(): Boolean = tiered != null + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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 + } - fun _json(): Optional = Optional.ofNullable(_json) + /** 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - fun visitUnit(unit: UnitConversionRateConfig): T + /** + * 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") - fun visitTiered(tiered: TieredConversionRateConfig): T + /** + * 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") /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. + * Returns the raw JSON value of [tierLowerBound]. * - * 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. + * 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]. * - * @throws OrbInvalidDataException in the default implementation. + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) + @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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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) } - return ConversionRateConfig(_json = json) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - } - 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") + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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}" } /** @@ -1656,12 +2212,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 @@ -1673,12 +2227,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt index 1a5fe9ea..b8ffaff1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingScalableMatrixWithUnitPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -142,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). */ @@ -156,6 +150,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). */ @@ -535,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)) /** @@ -557,6 +554,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)) @@ -1137,7 +1135,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() @@ -1145,6 +1143,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1258,7 +1257,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() @@ -1266,16 +1265,136 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = prorate.getOptional("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(): Optional = secondDimension.getOptional("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) @@ -1284,6 +1403,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1291,16 +1417,125 @@ 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() @JvmSynthetic 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?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * 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) @@ -1324,9 +1559,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: + * ```java + * .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 @@ -1336,6 +1589,11 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + prorate() + secondDimension() validated = true } @@ -1355,202 +1613,320 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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(): Optional = + secondDimensionValue.getOptional("second_dimension_value") - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } + /** + * 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 - /** 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, - ) { + /** + * 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 - fun unit(): Optional = Optional.ofNullable(unit) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tiered(): Optional = Optional.ofNullable(tiered) + @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: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { - fun isTiered(): Boolean = tiered != null + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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 + } - fun _json(): Optional = Optional.ofNullable(_json) + /** 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** @@ -1647,12 +2023,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 @@ -1664,12 +2038,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt index e77512a4..333389da 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingThresholdTotalAmountPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,6 +133,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). */ @@ -155,6 +149,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). */ @@ -530,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)) /** @@ -552,6 +549,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)) @@ -1128,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() @@ -1136,6 +1134,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1248,7 +1247,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,16 +1255,67 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = prorate.getOptional("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) @@ -1274,6 +1324,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1281,14 +1336,71 @@ 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() @JvmSynthetic 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?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * 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) @@ -1312,9 +1424,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: + * ```java + * .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 @@ -1324,6 +1447,8 @@ private constructor( return@apply } + consumptionTable().forEach { it.validate() } + prorate() validated = true } @@ -1343,202 +1468,246 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (consumptionTable.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** 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, - ) { + @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: + * ```java + * .threshold() + * .totalAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun unit(): Optional = Optional.ofNullable(unit) + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = consumptionTable.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + /** 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 asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } + private var validated: Boolean = false - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + threshold() + totalAmount() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (totalAmount.asKnown().isPresent) 1 else 0) - 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 ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) } - companion object { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } /** @@ -1635,12 +1804,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 @@ -1652,12 +1819,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt deleted file mode 100644 index 5e148cd9..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredBpsPrice.kt +++ /dev/null @@ -1,1548 +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.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 -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = billableMetricId.getOptional("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Optional = billedInAdvance.getOptional("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(): Optional = - billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = - conversionRateConfig.getOptional("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(): Optional = - dimensionalPriceConfiguration.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = - fixedPriceQuantity.getOptional("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(): Optional = - invoiceGroupingKey.getOptional("invoice_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(): Optional = - invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: - * ```java - * .cadence() - * .currency() - * .itemId() - * .modelType() - * .name() - * .tieredBpsConfig() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.billableMetricId] with `billableMetricId.orElse(null)`. */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. 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?) - - /** Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. 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)) - - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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?) - - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. 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: - * ```java - * 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: - * ```java - * 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)) - - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. 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)) - - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. 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?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * 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: - * ```java - * .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().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - 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 { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - 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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && 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 */ - } - - /* 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 */ - - 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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt index b22e725a..43dcdffc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,6 +133,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). */ @@ -155,6 +149,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). */ @@ -523,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)) /** @@ -545,6 +542,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_package pricing */ fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = tieredPackageConfig(JsonField.of(tieredPackageConfig)) @@ -1121,7 +1119,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() @@ -1129,6 +1127,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1241,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() @@ -1249,35 +1248,143 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package pricing */ class TieredPackageConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = 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: + * ```java + * .packageSize() + * .tiers() + * ``` + */ @JvmStatic 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() @JvmSynthetic 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. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1301,9 +1408,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: + * ```java + * .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 @@ -1313,6 +1432,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1332,201 +1453,242 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = "TieredPackageConfig{additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** 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, - ) { + @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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun unit(): Optional = Optional.ofNullable(unit) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + /** 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 asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): ConversionRateConfig = 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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } + private var validated: Boolean = false - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + perUnit() + tierLowerBound() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) - 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 Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) } - companion object { + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } - } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } - return ConversionRateConfig(_json = json) - } - } + override fun hashCode(): Int = hashCode - 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") - } - } - } + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -1623,12 +1785,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 @@ -1640,12 +1800,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt index 5166aa47..7ddc326a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingTieredPackageWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -142,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). */ @@ -156,6 +150,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 +528,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 +551,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)) @@ -1131,7 +1129,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() @@ -1139,6 +1137,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1251,7 +1250,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,16 +1258,65 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1277,6 +1325,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1284,15 +1338,62 @@ 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() @JvmSynthetic 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) @@ -1316,9 +1417,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: + * ```java + * .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 @@ -1328,6 +1441,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1347,202 +1462,288 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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") - override fun hashCode(): Int = hashCode + /** + * 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 toString() = - "TieredPackageWithMinimumConfig{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 - /** 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, - ) { + /** + * 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 - fun unit(): Optional = Optional.ofNullable(unit) + /** + * 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 tiered(): Optional = Optional.ofNullable(tiered) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isUnit(): Boolean = unit != 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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isTiered(): Boolean = tiered != null + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun _json(): Optional = Optional.ofNullable(_json) + /** 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 accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + minimumAmount() + perUnit() + tierLowerBound() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, perUnit, tierLowerBound, additionalProperties) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } - } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } - return ConversionRateConfig(_json = json) - } - } + override fun hashCode(): Int = hashCode - 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") - } - } - } + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -1639,12 +1840,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 @@ -1656,12 +1855,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt index c5526bfa..803a833a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,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). */ @@ -155,6 +148,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). */ @@ -519,6 +514,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 +537,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered pricing */ fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) /** @@ -1116,7 +1113,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() @@ -1124,6 +1121,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1236,7 +1234,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() @@ -1244,184 +1242,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1516,12 +1336,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 @@ -1533,12 +1351,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt index d367b358..7010c11b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingTieredWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,6 +133,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). */ @@ -155,6 +149,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 +523,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 +546,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)) @@ -1126,7 +1124,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() @@ -1134,6 +1132,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1246,7 +1245,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,16 +1253,84 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = + hideZeroAmountTiers.getOptional("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(): Optional = prorate.getOptional("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) @@ -1271,6 +1338,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1278,13 +1350,75 @@ 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() @JvmSynthetic 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) @@ -1308,9 +1442,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: + * ```java + * .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 @@ -1320,6 +1466,9 @@ private constructor( return@apply } + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() validated = true } @@ -1339,202 +1488,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** 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, - ) { + /** + * 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 unit(): Optional = Optional.ofNullable(unit) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tiered(): Optional = Optional.ofNullable(tiered) + @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: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun isTiered(): Boolean = tiered != null + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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 _json(): Optional = Optional.ofNullable(_json) + /** 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 accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + minimumAmount() + tierLowerBound() + unitAmount() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, tierLowerBound, unitAmount, additionalProperties) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } /** @@ -1631,12 +1875,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 @@ -1648,12 +1890,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt index 558ca41c..bb9ebf2a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingTieredWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,6 +133,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). */ @@ -155,6 +149,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). */ @@ -530,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)) /** @@ -552,6 +549,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)) @@ -1128,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() @@ -1136,6 +1134,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1248,7 +1247,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,16 +1255,43 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_with_proration pricing */ class TieredWithProrationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1274,6 +1300,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1281,13 +1312,44 @@ private constructor( /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic 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) @@ -1311,9 +1373,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: + * ```java + * .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 @@ -1323,6 +1395,7 @@ private constructor( return@apply } + tiers().forEach { it.validate() } validated = true } @@ -1342,202 +1415,245 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown().getOrNull()?.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()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** 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, - ) { + @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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun unit(): Optional = Optional.ofNullable(unit) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + 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 + } - fun isTiered(): Boolean = tiered != null + /** 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 asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): ConversionRateConfig = 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } + private var validated: Boolean = false - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + tierLowerBound() + unitAmount() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) - 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 Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } - companion object { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } - } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - return ConversionRateConfig(_json = json) - } - } + override fun hashCode(): Int = hashCode - 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") - } - } - } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -1634,12 +1750,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 @@ -1651,12 +1765,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt index 443cf901..75607f1d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingUnitPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,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). */ @@ -155,6 +148,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). */ @@ -519,6 +514,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 +537,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** @@ -1114,7 +1111,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() @@ -1122,6 +1119,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1234,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() @@ -1242,184 +1240,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1514,12 +1334,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 @@ -1531,12 +1349,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt index 10762b1d..4a85f81d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingUnitWithPercentPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,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). */ @@ -155,6 +148,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 +522,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 +545,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)) @@ -1125,7 +1122,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() @@ -1133,6 +1130,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1245,7 +1243,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() @@ -1253,16 +1251,64 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1270,6 +1316,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithPercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1277,13 +1329,41 @@ 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() @JvmSynthetic 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) @@ -1307,9 +1387,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: + * ```java + * .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 @@ -1319,6 +1411,8 @@ private constructor( return@apply } + percent() + unitAmount() validated = true } @@ -1338,202 +1432,28 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (percent.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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") - } - } - } + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -1630,12 +1550,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 @@ -1647,12 +1565,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-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt index 89f3265f..a46c6e1d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewFloatingUnitWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, @@ -141,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). */ @@ -155,6 +148,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 +522,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 +545,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)) @@ -1126,7 +1123,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() @@ -1134,6 +1131,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1246,7 +1244,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,16 +1252,47 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1271,6 +1300,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1278,13 +1312,27 @@ private constructor( /** A builder for [UnitWithProrationConfig]. */ class Builder internal constructor() { + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic 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) @@ -1308,9 +1356,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: + * ```java + * .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 @@ -1320,6 +1378,7 @@ private constructor( return@apply } + unitAmount() validated = true } @@ -1337,204 +1396,24 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + @JvmSynthetic internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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") - } - } - } + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -1631,12 +1510,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 @@ -1648,12 +1525,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-java-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt index b08b9e79..d83adc72 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewMaximum +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val maximumAmount: JsonField, @@ -666,7 +667,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() @@ -785,7 +786,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() @@ -930,7 +931,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() @@ -943,12 +944,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-java-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt index 6864dc70..597d20b9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewMinimum +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val itemId: JsonField, @@ -702,7 +703,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() @@ -821,7 +822,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() @@ -966,7 +967,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() @@ -979,12 +980,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-java-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt index 216df0db..75bd6e7c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPercentageDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val percentageDiscount: JsonField, @@ -668,7 +669,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() @@ -787,7 +788,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() @@ -932,7 +933,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() @@ -945,12 +946,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt deleted file mode 100644 index 1bb29b70..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBpsPrice.kt +++ /dev/null @@ -1,1594 +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.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 -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = billableMetricId.getOptional("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Optional = billedInAdvance.getOptional("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(): Optional = - billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = - conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = - dimensionalPriceConfiguration.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = - fixedPriceQuantity.getOptional("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(): Optional = - invoiceGroupingKey.getOptional("invoice_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(): Optional = - invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: - * ```java - * .bpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.billableMetricId] with `billableMetricId.orElse(null)`. */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. 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?) - - /** Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. 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)) - - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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?) - - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. 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: - * ```java - * 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: - * ```java - * 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)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. 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)) - - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. 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)) - - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. 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?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * 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)) - - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = referenceId(referenceId.getOrNull()) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * 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: - * ```java - * .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().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.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. - */ - @JvmSynthetic - internal fun validity(): Int = - (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - 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 { - - @JvmField val BPS = of("bps") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - 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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is 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 */ - } - - /* 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 */ - - 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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt index bd9f78b4..8960972a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, @@ -122,6 +113,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). */ @@ -144,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). */ @@ -511,6 +506,7 @@ private constructor( additionalProperties = newPlanBulkPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk pricing */ fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) /** @@ -544,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)) /** @@ -1165,7 +1162,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,6 +1170,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1285,7 +1283,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() @@ -1293,184 +1291,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1565,12 +1385,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 +1400,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt index 1a79d7bd..bebc0f4b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanBulkWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, @@ -122,6 +114,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). */ @@ -145,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). */ @@ -515,6 +511,7 @@ private constructor( additionalProperties = newPlanBulkWithProrationPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_proration pricing */ fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) @@ -552,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)) /** @@ -1032,16 +1030,43 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) + /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1049,6 +1074,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1056,13 +1086,41 @@ private constructor( /** A builder for [BulkWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic 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) @@ -1086,9 +1144,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: + * ```java + * .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 @@ -1098,6 +1166,7 @@ private constructor( return@apply } + tiers().forEach { it.validate() } validated = true } @@ -1117,24 +1186,248 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = tierLowerBound.getOptional("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: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.tierLowerBound] with `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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. */ @@ -1278,7 +1571,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() @@ -1286,6 +1579,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1398,7 +1692,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,184 +1700,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1678,12 +1794,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 @@ -1695,12 +1809,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt index 02e6a5b6..06dd52f3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanCumulativeGroupedBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, @@ -130,6 +122,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). */ @@ -145,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). */ @@ -532,6 +528,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)) @@ -557,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)) /** @@ -1178,7 +1176,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() @@ -1186,16 +1184,66 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1204,6 +1252,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1211,14 +1265,58 @@ 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() @JvmSynthetic 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) @@ -1242,9 +1340,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: + * ```java + * .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 @@ -1254,6 +1364,8 @@ private constructor( return@apply } + dimensionValues().forEach { it.validate() } + group() validated = true } @@ -1273,26 +1385,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown().isPresent) 1 else 0) + + /** 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: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1405,7 +1788,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() @@ -1413,184 +1796,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1685,12 +1890,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 @@ -1702,12 +1905,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt index 11518450..5038dd58 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanGroupedAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedAllocationConfig: JsonField, @@ -130,6 +121,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). */ @@ -145,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). */ @@ -526,6 +521,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_allocation pricing */ fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) @@ -552,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)) /** @@ -1173,7 +1170,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() @@ -1181,16 +1178,90 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1198,6 +1269,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1205,13 +1283,60 @@ 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() @JvmSynthetic 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) @@ -1235,9 +1360,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: + * ```java + * .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 @@ -1247,6 +1386,9 @@ private constructor( return@apply } + allocation() + groupingKey() + overageUnitRate() validated = true } @@ -1266,26 +1408,33 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1398,7 +1547,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,184 +1555,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1678,12 +1649,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 @@ -1695,12 +1664,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt index c2351467..8addf51c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanGroupedTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedTieredPackageConfig: JsonField, @@ -130,6 +122,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). */ @@ -145,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). */ @@ -532,6 +528,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)) @@ -557,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)) /** @@ -1178,7 +1176,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() @@ -1186,16 +1184,86 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1204,6 +1272,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1211,14 +1286,77 @@ 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() @JvmSynthetic 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) @@ -1242,9 +1380,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: + * ```java + * .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 @@ -1254,6 +1406,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1273,26 +1428,249 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * 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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1405,7 +1783,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() @@ -1413,184 +1791,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1685,12 +1885,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 @@ -1702,12 +1900,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt index dd6be9a3..4571ae33 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanGroupedTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedTieredConfig: JsonField, @@ -130,6 +122,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). */ @@ -145,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). */ @@ -524,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)) @@ -549,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)) /** @@ -1170,7 +1168,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,35 +1176,137 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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: + * ```java + * .groupingKey() + * .tiers() + * ``` + */ @JvmStatic 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() @JvmSynthetic 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) @@ -1230,9 +1330,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: + * ```java + * .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 @@ -1242,6 +1354,8 @@ private constructor( return@apply } + groupingKey() + tiers().forEach { it.validate() } validated = true } @@ -1261,25 +1375,250 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1392,7 +1731,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() @@ -1400,184 +1739,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1672,12 +1833,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 @@ -1689,12 +1848,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt index 14ee1598..68431030 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanGroupedWithMeteredMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, @@ -131,6 +123,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). */ @@ -146,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). */ @@ -535,6 +531,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)) @@ -561,6 +558,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1182,7 +1180,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() @@ -1190,16 +1188,163 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1208,6 +1353,16 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1215,15 +1370,140 @@ 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() @JvmSynthetic 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) @@ -1247,9 +1527,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: + * ```java + * .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 @@ -1259,6 +1559,12 @@ private constructor( return@apply } + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } validated = true } @@ -1278,26 +1584,488 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * 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: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + 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 } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1410,7 +2178,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() @@ -1418,184 +2186,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1690,12 +2280,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 @@ -1707,12 +2295,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt index 26ed4ad4..cc44542c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanGroupedWithProratedMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithProratedMinimumConfig: JsonField, @@ -131,6 +122,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). */ @@ -146,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). */ @@ -535,6 +530,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)) @@ -561,6 +557,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1182,7 +1179,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() @@ -1190,16 +1187,83 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1208,6 +1272,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1215,15 +1286,59 @@ 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() @JvmSynthetic 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) @@ -1247,9 +1362,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: + * ```java + * .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 @@ -1259,6 +1388,9 @@ private constructor( return@apply } + groupingKey() + minimum() + unitRate() validated = true } @@ -1278,26 +1410,33 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1410,7 +1549,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() @@ -1418,184 +1557,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1690,12 +1651,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 @@ -1707,12 +1666,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt index 3bec98dd..1fdfa4cc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanMatrixPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -533,6 +528,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix pricing */ fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) /** @@ -546,6 +542,7 @@ private constructor( this.matrixConfig = matrixConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1167,7 +1164,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() @@ -1175,6 +1172,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1287,7 +1285,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() @@ -1295,184 +1293,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1567,12 +1387,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 @@ -1584,12 +1402,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt index b5e8e778..c501222c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanMatrixWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -145,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). */ @@ -543,6 +538,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)) @@ -557,6 +553,7 @@ private constructor( matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1178,7 +1175,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() @@ -1186,6 +1183,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1298,7 +1296,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,184 +1304,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1578,12 +1398,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 @@ -1595,12 +1413,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt index 4021d488..3d27388c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanMatrixWithDisplayNamePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -145,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). */ @@ -543,6 +539,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)) @@ -557,6 +554,7 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1178,7 +1176,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() @@ -1186,16 +1184,66 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1204,6 +1252,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1211,14 +1265,56 @@ 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() @JvmSynthetic 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) @@ -1242,9 +1338,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: + * ```java + * .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 @@ -1254,6 +1362,8 @@ private constructor( return@apply } + dimension() + unitAmounts().forEach { it.validate() } validated = true } @@ -1273,26 +1383,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1405,7 +1786,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() @@ -1413,184 +1794,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1685,12 +1888,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 @@ -1702,12 +1903,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt index 4729bd17..69a0ccc8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanMaxGroupTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -145,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). */ @@ -543,6 +539,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)) @@ -557,6 +554,7 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1178,7 +1176,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() @@ -1186,16 +1184,85 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1204,6 +1271,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1211,14 +1285,74 @@ 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() @JvmSynthetic 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) @@ -1242,9 +1376,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: + * ```java + * .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 @@ -1254,6 +1402,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1273,26 +1424,254 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1405,7 +1784,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() @@ -1413,184 +1792,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1685,12 +1886,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 @@ -1702,12 +1901,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt similarity index 80% rename from orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt rename to orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt index 475ee2f8..f7f772fc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.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 @@ -29,11 +19,12 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class NewSubscriptionBulkBpsPrice +class NewPlanMinimumCompositePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkBpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, + private val minimumConfig: JsonField, private val modelType: JsonField, private val name: JsonField, private val billableMetricId: JsonField, @@ -54,11 +45,11 @@ private constructor( @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("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonField = JsonMissing.of(), @@ -100,9 +91,9 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkBpsConfig, cadence, itemId, + minimumConfig, modelType, name, billableMetricId, @@ -122,28 +113,32 @@ private constructor( ) /** + * The cadence to bill for this price on. + * * @throws OrbInvalidDataException if 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") /** - * The cadence to bill for this price on. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * 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 itemId(): String = itemId.getRequired("item_id") + 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). */ @@ -273,15 +268,6 @@ private constructor( */ fun referenceId(): Optional = referenceId.getOptional("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]. * @@ -296,6 +282,15 @@ private constructor( */ @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]. * @@ -448,13 +443,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewSubscriptionBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of [NewPlanMinimumCompositePrice]. * * The following fields are required: * ```java - * .bulkBpsConfig() * .cadence() * .itemId() + * .minimumConfig() * .modelType() * .name() * ``` @@ -462,12 +457,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkBpsPrice]. */ + /** A builder for [NewPlanMinimumCompositePrice]. */ class Builder internal constructor() { - private var bulkBpsConfig: JsonField? = null 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() @@ -489,40 +484,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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 + 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 = - 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 + 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. */ @@ -547,6 +529,21 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** 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 + } + + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -926,26 +923,26 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkBpsPrice]. + * Returns an immutable instance of [NewPlanMinimumCompositePrice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .bulkBpsConfig() * .cadence() * .itemId() + * .minimumConfig() * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), + fun build(): NewPlanMinimumCompositePrice = + NewPlanMinimumCompositePrice( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), checkRequired("modelType", modelType), checkRequired("name", name), billableMetricId, @@ -967,14 +964,14 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkBpsPrice = apply { + fun validate(): NewPlanMinimumCompositePrice = apply { if (validated) { return@apply } - bulkBpsConfig().validate() cadence().validate() itemId() + minimumConfig().validate() modelType().validate() name() billableMetricId() @@ -1008,9 +1005,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (minimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (modelType.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -1168,7 +1165,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() @@ -1176,6 +1173,215 @@ private constructor( override fun toString() = value.toString() } + /** 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(): Optional = prorated.getOptional("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: + * ```java + * .minimumAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (prorated.asKnown().isPresent) 1 else 0) + + 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}" + } + + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1190,14 +1396,14 @@ private constructor( companion object { - @JvmField val BULK_BPS = of("bulk_bps") + @JvmField val MINIMUM = of("minimum") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - BULK_BPS + MINIMUM } /** @@ -1210,7 +1416,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BULK_BPS, + MINIMUM, /** * An enum member indicating that [ModelType] was instantiated with an unknown value. */ @@ -1226,7 +1432,7 @@ private constructor( */ fun value(): Value = when (this) { - BULK_BPS -> Value.BULK_BPS + MINIMUM -> Value.MINIMUM else -> Value._UNKNOWN } @@ -1240,7 +1446,7 @@ private constructor( */ fun known(): Known = when (this) { - BULK_BPS -> Known.BULK_BPS + MINIMUM -> Known.MINIMUM else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -1288,7 +1494,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() @@ -1296,184 +1502,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1568,12 +1596,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 @@ -1585,15 +1611,54 @@ 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 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 } - /* 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( + 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() = - "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}" + "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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt index 6abe5251..2ba731b6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -533,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)) /** @@ -555,6 +551,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package pricing */ fun packageConfig(packageConfig: PackageConfig) = packageConfig(JsonField.of(packageConfig)) /** @@ -1167,7 +1164,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() @@ -1175,6 +1172,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1287,7 +1285,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() @@ -1295,184 +1293,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1567,12 +1387,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 @@ -1584,12 +1402,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt index de1b4adb..15e06f45 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanPackageWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -543,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)) /** @@ -565,6 +561,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)) @@ -1178,7 +1175,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() @@ -1186,6 +1183,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1298,7 +1296,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,16 +1304,90 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1324,6 +1396,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1331,14 +1410,60 @@ 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() @JvmSynthetic 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) @@ -1362,9 +1487,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: + * ```java + * .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 @@ -1374,6 +1513,9 @@ private constructor( return@apply } + allocation() + packageAmount() + packageSize() validated = true } @@ -1393,202 +1535,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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") - } - } - } + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" } /** @@ -1685,12 +1655,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 @@ -1702,12 +1670,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt index 56dba4c1..c3d38800 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanScalableMatrixWithTieredPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -140,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). */ @@ -154,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). */ @@ -550,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)) /** @@ -572,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 ) = @@ -1194,7 +1192,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,6 +1200,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1315,7 +1314,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() @@ -1323,16 +1322,110 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = secondDimension.getOptional("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) @@ -1341,6 +1434,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1348,16 +1448,115 @@ 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() @JvmSynthetic 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)) + + /** Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * 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) @@ -1381,9 +1580,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: + * ```java + * .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 @@ -1393,6 +1609,10 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() validated = true } @@ -1412,202 +1632,538 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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(): Optional = + secondDimensionValue.getOptional("second_dimension_value") - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" - } + /** + * 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 - /** 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, - ) { + /** + * 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 - fun unit(): Optional = Optional.ofNullable(unit) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tiered(): Optional = Optional.ofNullable(tiered) + @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: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { - fun isTiered(): Boolean = tiered != null + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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 + } - fun _json(): Optional = Optional.ofNullable(_json) + /** 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - fun visitUnit(unit: UnitConversionRateConfig): T + /** + * 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") - fun visitTiered(tiered: TieredConversionRateConfig): T + /** + * 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") /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. + * Returns the raw JSON value of [tierLowerBound]. * - * 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. + * 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]. * - * @throws OrbInvalidDataException in the default implementation. + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) + @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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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) } - return ConversionRateConfig(_json = json) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - } - 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") + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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}" } /** @@ -1704,12 +2260,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 @@ -1721,12 +2275,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt index ea62e58f..15bd4870 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanScalableMatrixWithUnitPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -139,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). */ @@ -153,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). */ @@ -547,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)) /** @@ -569,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)) @@ -1186,7 +1184,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() @@ -1194,6 +1192,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1307,7 +1306,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,16 +1314,136 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = prorate.getOptional("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(): Optional = secondDimension.getOptional("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) @@ -1333,6 +1452,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1340,16 +1466,125 @@ 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() @JvmSynthetic 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?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * 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) @@ -1373,9 +1608,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: + * ```java + * .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 @@ -1385,6 +1638,11 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + prorate() + secondDimension() validated = true } @@ -1404,202 +1662,320 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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(): Optional = + secondDimensionValue.getOptional("second_dimension_value") - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } + /** + * 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 - /** 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, - ) { + /** + * 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 - fun unit(): Optional = Optional.ofNullable(unit) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tiered(): Optional = Optional.ofNullable(tiered) + @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: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { - fun isTiered(): Boolean = tiered != null + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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 + } - fun _json(): Optional = Optional.ofNullable(_json) + /** 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** @@ -1696,12 +2072,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 @@ -1713,12 +2087,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt index cb2ab412..ddbcdfc1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanThresholdTotalAmountPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -543,6 +539,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -565,6 +562,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)) @@ -1178,7 +1176,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() @@ -1186,6 +1184,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1298,7 +1297,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,16 +1305,67 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = prorate.getOptional("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) @@ -1324,6 +1374,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1331,14 +1386,71 @@ 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() @JvmSynthetic 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?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * 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) @@ -1362,9 +1474,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: + * ```java + * .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 @@ -1374,6 +1497,8 @@ private constructor( return@apply } + consumptionTable().forEach { it.validate() } + prorate() validated = true } @@ -1393,202 +1518,246 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (consumptionTable.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** 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, - ) { + @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: + * ```java + * .threshold() + * .totalAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun unit(): Optional = Optional.ofNullable(unit) + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = consumptionTable.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + /** 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 asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } + private var validated: Boolean = false - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + threshold() + totalAmount() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (totalAmount.asKnown().isPresent) 1 else 0) - 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 ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) } - companion object { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } /** @@ -1685,12 +1854,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 @@ -1702,12 +1869,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt deleted file mode 100644 index 42126010..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTierWithProrationPrice.kt +++ /dev/null @@ -1,1710 +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.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 -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = billableMetricId.getOptional("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Optional = billedInAdvance.getOptional("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(): Optional = - billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = - conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = - dimensionalPriceConfiguration.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = - fixedPriceQuantity.getOptional("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(): Optional = - invoiceGroupingKey.getOptional("invoice_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(): Optional = - invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: - * ```java - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredWithProrationConfig() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.billableMetricId] with `billableMetricId.orElse(null)`. */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. 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?) - - /** Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. 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)) - - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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?) - - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. 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: - * ```java - * 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: - * ```java - * 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)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. 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)) - - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. 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)) - - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. 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?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * 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)) - - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = referenceId(referenceId.getOrNull()) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * 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: - * ```java - * .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().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.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. - */ - @JvmSynthetic - internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - 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 { - - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - 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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is 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 */ - } - - /* 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 */ - - 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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt deleted file mode 100644 index 81b09aea..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredBpsPrice.kt +++ /dev/null @@ -1,1599 +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.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 -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = billableMetricId.getOptional("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Optional = billedInAdvance.getOptional("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(): Optional = - billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = - conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = - dimensionalPriceConfiguration.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = - fixedPriceQuantity.getOptional("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(): Optional = - invoiceGroupingKey.getOptional("invoice_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(): Optional = - invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: - * ```java - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredBpsConfig() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.billableMetricId] with `billableMetricId.orElse(null)`. */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. 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?) - - /** Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. 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)) - - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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?) - - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. 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: - * ```java - * 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: - * ```java - * 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)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. 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)) - - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. 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)) - - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. 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?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * 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)) - - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = referenceId(referenceId.getOrNull()) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * 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: - * ```java - * .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().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.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. - */ - @JvmSynthetic - internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - 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 { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - 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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is 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 */ - } - - /* 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 */ - - 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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt index 9f38dceb..c8ee51de 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -535,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)) /** @@ -557,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)) @@ -1170,7 +1168,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,6 +1176,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1290,7 +1289,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() @@ -1298,35 +1297,143 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package pricing */ class TieredPackageConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = 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: + * ```java + * .packageSize() + * .tiers() + * ``` + */ @JvmStatic 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() @JvmSynthetic 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. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1350,9 +1457,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: + * ```java + * .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 @@ -1362,6 +1481,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1381,201 +1502,242 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = "TieredPackageConfig{additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** 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, - ) { + @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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun unit(): Optional = Optional.ofNullable(unit) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + /** 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 asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): ConversionRateConfig = 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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } + private var validated: Boolean = false - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + perUnit() + tierLowerBound() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) - 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 Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) } - companion object { + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } - } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } - return ConversionRateConfig(_json = json) - } - } + override fun hashCode(): Int = hashCode - 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") - } - } - } + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -1672,12 +1834,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 @@ -1689,12 +1849,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt index 2b7362cc..4079cc02 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanTieredPackageWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -139,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). */ @@ -153,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). */ @@ -546,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)) /** @@ -568,6 +565,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)) @@ -1182,7 +1180,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() @@ -1190,6 +1188,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1302,7 +1301,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() @@ -1310,16 +1309,65 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1328,6 +1376,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1335,15 +1389,62 @@ 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() @JvmSynthetic 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) @@ -1367,9 +1468,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: + * ```java + * .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 @@ -1379,6 +1492,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1398,202 +1513,288 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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") - override fun hashCode(): Int = hashCode + /** + * 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 toString() = - "TieredPackageWithMinimumConfig{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 - /** 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, - ) { + /** + * 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 - fun unit(): Optional = Optional.ofNullable(unit) + /** + * 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 tiered(): Optional = Optional.ofNullable(tiered) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isUnit(): Boolean = unit != 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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isTiered(): Boolean = tiered != null + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun _json(): Optional = Optional.ofNullable(_json) + /** 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 accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + minimumAmount() + perUnit() + tierLowerBound() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, perUnit, tierLowerBound, additionalProperties) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } - } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } - return ConversionRateConfig(_json = json) - } - } + override fun hashCode(): Int = hashCode - 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") - } - } - } + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -1690,12 +1891,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 @@ -1707,12 +1906,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt index 34a8f718..38bf989d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -533,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)) /** @@ -555,6 +551,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered pricing */ fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) /** @@ -1167,7 +1164,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() @@ -1175,6 +1172,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1287,7 +1285,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() @@ -1295,184 +1293,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1567,12 +1387,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 @@ -1584,12 +1402,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt index 099cc9ec..b649f74b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanTieredWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -537,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)) /** @@ -559,6 +556,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)) @@ -1173,7 +1171,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() @@ -1181,6 +1179,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1293,7 +1292,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,16 +1300,84 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = + hideZeroAmountTiers.getOptional("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(): Optional = prorate.getOptional("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) @@ -1318,6 +1385,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1325,13 +1397,75 @@ 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() @JvmSynthetic 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) @@ -1355,9 +1489,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: + * ```java + * .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 @@ -1367,6 +1513,9 @@ private constructor( return@apply } + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() validated = true } @@ -1386,202 +1535,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** 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, - ) { + /** + * 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 unit(): Optional = Optional.ofNullable(unit) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tiered(): Optional = Optional.ofNullable(tiered) + @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: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun isTiered(): Boolean = tiered != null + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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 _json(): Optional = Optional.ofNullable(_json) + /** 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 accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + minimumAmount() + tierLowerBound() + unitAmount() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, tierLowerBound, unitAmount, additionalProperties) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } /** @@ -1678,12 +1922,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 @@ -1695,12 +1937,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt index 30519372..5dcd3e75 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanUnitPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -533,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)) /** @@ -555,6 +551,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** @@ -1165,7 +1162,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,6 +1170,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1285,7 +1283,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() @@ -1293,184 +1291,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1565,12 +1385,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 +1400,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt index 3aa71c94..2070811b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanUnitWithPercentPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -536,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)) /** @@ -558,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)) @@ -1171,7 +1168,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() @@ -1179,6 +1176,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1291,7 +1289,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,16 +1297,64 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1316,6 +1362,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithPercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1323,13 +1375,41 @@ 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() @JvmSynthetic 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) @@ -1353,9 +1433,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: + * ```java + * .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 @@ -1365,6 +1457,8 @@ private constructor( return@apply } + percent() + unitAmount() validated = true } @@ -1384,202 +1478,28 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (percent.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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") - } - } - } + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -1676,12 +1596,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 @@ -1693,12 +1611,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt index effeab8c..47b37768 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewPlanUnitWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -537,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)) /** @@ -559,6 +555,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)) @@ -1173,7 +1170,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() @@ -1181,6 +1178,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1293,7 +1291,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,16 +1299,47 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1318,6 +1347,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1325,13 +1359,27 @@ private constructor( /** A builder for [UnitWithProrationConfig]. */ class Builder internal constructor() { + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic 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) @@ -1355,9 +1403,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: + * ```java + * .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 @@ -1367,6 +1425,7 @@ private constructor( return@apply } + unitAmount() validated = true } @@ -1384,204 +1443,24 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + @JvmSynthetic internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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") - } - } - } + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -1678,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 @@ -1695,12 +1572,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-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt index a5b3d4bb..c34de26d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt +++ b/orb-java-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, @@ -155,12 +156,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-java-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt index 1dd63e71..093dbac4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt @@ -18,6 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class NewSphereConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val taxExempt: JsonField, private val taxProvider: JsonField, @@ -309,7 +310,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() @@ -322,12 +323,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt deleted file mode 100644 index bf0f6dbf..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBpsPrice.kt +++ /dev/null @@ -1,1594 +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.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 -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = billableMetricId.getOptional("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Optional = billedInAdvance.getOptional("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(): Optional = - billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = - conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = - dimensionalPriceConfiguration.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = - fixedPriceQuantity.getOptional("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(): Optional = - invoiceGroupingKey.getOptional("invoice_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(): Optional = - invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: - * ```java - * .bpsConfig() - * .cadence() - * .itemId() - * .modelType() - * .name() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.billableMetricId] with `billableMetricId.orElse(null)`. */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. 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?) - - /** Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. 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)) - - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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?) - - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. 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: - * ```java - * 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: - * ```java - * 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)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. 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)) - - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. 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)) - - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. 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?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * 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)) - - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = referenceId(referenceId.getOrNull()) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * 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: - * ```java - * .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().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.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. - */ - @JvmSynthetic - internal fun validity(): Int = - (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - 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 { - - @JvmField val BPS = of("bps") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - 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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is 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 */ - } - - /* 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 */ - - 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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt index dd8b4100..b10d26b6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, @@ -122,6 +113,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). */ @@ -144,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). */ @@ -511,6 +506,7 @@ private constructor( additionalProperties = newSubscriptionBulkPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk pricing */ fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) /** @@ -544,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)) /** @@ -1165,7 +1162,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,6 +1170,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1285,7 +1283,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() @@ -1293,184 +1291,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1565,12 +1385,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 +1400,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt index 89e74177..7ce89bc0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionBulkWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, @@ -122,6 +114,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). */ @@ -145,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). */ @@ -520,6 +516,7 @@ private constructor( newSubscriptionBulkWithProrationPrice.additionalProperties.toMutableMap() } + /** Configuration for bulk_with_proration pricing */ fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) @@ -557,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)) /** @@ -1037,16 +1035,43 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) + /** Configuration for bulk_with_proration pricing */ class BulkWithProrationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1054,6 +1079,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1061,13 +1091,41 @@ private constructor( /** A builder for [BulkWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic 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) @@ -1091,9 +1149,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: + * ```java + * .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 @@ -1103,6 +1171,7 @@ private constructor( return@apply } + tiers().forEach { it.validate() } validated = true } @@ -1122,24 +1191,248 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = tierLowerBound.getOptional("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: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.tierLowerBound] with `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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. */ @@ -1283,7 +1576,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() @@ -1291,6 +1584,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1403,7 +1697,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() @@ -1411,184 +1705,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1683,12 +1799,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 @@ -1700,12 +1814,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt index f0e93cbd..1aa03513 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionCumulativeGroupedBulkPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, @@ -130,6 +122,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). */ @@ -145,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). */ @@ -533,6 +529,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)) @@ -558,6 +555,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1179,7 +1177,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() @@ -1187,16 +1185,66 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for cumulative_grouped_bulk pricing */ class CumulativeGroupedBulkConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1205,6 +1253,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1212,14 +1266,58 @@ 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() @JvmSynthetic 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) @@ -1243,9 +1341,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: + * ```java + * .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 @@ -1255,6 +1365,8 @@ private constructor( return@apply } + dimensionValues().forEach { it.validate() } + group() validated = true } @@ -1274,26 +1386,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown().isPresent) 1 else 0) + + /** 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: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1406,7 +1789,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() @@ -1414,184 +1797,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1686,12 +1891,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 @@ -1703,12 +1906,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt index 4af44d50..40d24c3a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionGroupedAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedAllocationConfig: JsonField, @@ -130,6 +121,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). */ @@ -145,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). */ @@ -531,6 +526,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_allocation pricing */ fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) @@ -557,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)) /** @@ -1178,7 +1175,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() @@ -1186,16 +1183,90 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_allocation pricing */ class GroupedAllocationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1203,6 +1274,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1210,13 +1288,60 @@ 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() @JvmSynthetic 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) @@ -1240,9 +1365,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: + * ```java + * .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 @@ -1252,6 +1391,9 @@ private constructor( return@apply } + allocation() + groupingKey() + overageUnitRate() validated = true } @@ -1271,26 +1413,33 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1403,7 +1552,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() @@ -1411,184 +1560,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1683,12 +1654,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 @@ -1700,12 +1669,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt index f84d7b2b..931fbed2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionGroupedTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedTieredPackageConfig: JsonField, @@ -130,6 +122,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). */ @@ -145,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). */ @@ -533,6 +529,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)) @@ -558,6 +555,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1179,7 +1177,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() @@ -1187,16 +1185,86 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered_package pricing */ class GroupedTieredPackageConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1205,6 +1273,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1212,14 +1287,77 @@ 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() @JvmSynthetic 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) @@ -1243,9 +1381,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: + * ```java + * .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 @@ -1255,6 +1407,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1274,26 +1429,249 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * 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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1406,7 +1784,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() @@ -1414,184 +1792,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1686,12 +1886,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 @@ -1703,12 +1901,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt index f645c3ff..6fa3c7b9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionGroupedTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedTieredConfig: JsonField, @@ -130,6 +122,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). */ @@ -145,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). */ @@ -530,6 +526,7 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for grouped_tiered pricing */ fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = groupedTieredConfig(JsonField.of(groupedTieredConfig)) @@ -555,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)) /** @@ -1176,7 +1174,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() @@ -1184,35 +1182,137 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_tiered pricing */ class GroupedTieredConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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: + * ```java + * .groupingKey() + * .tiers() + * ``` + */ @JvmStatic 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() @JvmSynthetic 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) @@ -1236,9 +1336,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: + * ```java + * .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 @@ -1248,6 +1360,8 @@ private constructor( return@apply } + groupingKey() + tiers().forEach { it.validate() } validated = true } @@ -1267,25 +1381,250 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1398,7 +1737,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,184 +1745,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1678,12 +1839,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 @@ -1695,12 +1854,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt index a5d9af30..3d0a16ff 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionGroupedWithMeteredMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, @@ -131,6 +123,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). */ @@ -146,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). */ @@ -537,6 +533,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)) @@ -563,6 +560,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1184,7 +1182,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,16 +1190,163 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_metered_minimum pricing */ class GroupedWithMeteredMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1210,6 +1355,16 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1217,15 +1372,140 @@ 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() @JvmSynthetic 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) @@ -1249,9 +1529,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: + * ```java + * .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 @@ -1261,6 +1561,12 @@ private constructor( return@apply } + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } validated = true } @@ -1280,26 +1586,488 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * 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: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + 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 } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1412,7 +2180,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,184 +2188,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1692,12 +2282,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 @@ -1709,12 +2297,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt index 41aaf035..477c3494 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionGroupedWithProratedMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val groupedWithProratedMinimumConfig: JsonField, @@ -131,6 +122,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). */ @@ -146,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). */ @@ -537,6 +532,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)) @@ -563,6 +559,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1184,7 +1181,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,16 +1189,83 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_prorated_minimum pricing */ class GroupedWithProratedMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1210,6 +1274,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1217,15 +1288,59 @@ 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() @JvmSynthetic 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) @@ -1249,9 +1364,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: + * ```java + * .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 @@ -1261,6 +1390,9 @@ private constructor( return@apply } + groupingKey() + minimum() + unitRate() validated = true } @@ -1280,26 +1412,33 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1412,7 +1551,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,184 +1559,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1692,12 +1653,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 @@ -1709,12 +1668,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt index a76d7c36..eb63bedb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionMatrixPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -533,6 +528,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix pricing */ fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) /** @@ -546,6 +542,7 @@ private constructor( this.matrixConfig = matrixConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1167,7 +1164,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() @@ -1175,6 +1172,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1287,7 +1285,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() @@ -1295,184 +1293,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1567,12 +1387,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 @@ -1584,12 +1402,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt index 6b43e086..1b57eceb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionMatrixWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -145,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). */ @@ -544,6 +539,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)) @@ -558,6 +554,7 @@ private constructor( matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1179,7 +1176,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() @@ -1187,6 +1184,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1299,7 +1297,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() @@ -1307,184 +1305,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1579,12 +1399,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 @@ -1596,12 +1414,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt index 516d132a..17fb78a4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionMatrixWithDisplayNamePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -145,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). */ @@ -544,6 +540,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)) @@ -558,6 +555,7 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1179,7 +1177,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() @@ -1187,16 +1185,66 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for matrix_with_display_name pricing */ class MatrixWithDisplayNameConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1205,6 +1253,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1212,14 +1266,56 @@ 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() @JvmSynthetic 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) @@ -1243,9 +1339,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: + * ```java + * .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 @@ -1255,6 +1363,8 @@ private constructor( return@apply } + dimension() + unitAmounts().forEach { it.validate() } validated = true } @@ -1274,26 +1384,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1406,7 +1787,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() @@ -1414,184 +1795,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1686,12 +1889,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 @@ -1703,12 +1904,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt index 6394f50d..8f12f577 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionMaxGroupTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -145,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). */ @@ -544,6 +540,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)) @@ -558,6 +555,7 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -1179,7 +1177,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() @@ -1187,16 +1185,85 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for max_group_tiered_package pricing */ class MaxGroupTieredPackageConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1205,6 +1272,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1212,14 +1286,74 @@ 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() @JvmSynthetic 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) @@ -1243,9 +1377,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: + * ```java + * .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 @@ -1255,6 +1403,9 @@ private constructor( return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1274,26 +1425,254 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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 { /** @@ -1406,7 +1785,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() @@ -1414,184 +1793,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1686,12 +1887,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 @@ -1703,12 +1902,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-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt similarity index 80% rename from orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt rename to orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt index 5d49f502..e3b08258 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkBpsPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.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 @@ -29,11 +19,12 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class NewPlanBulkBpsPrice +class NewSubscriptionMinimumCompositePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkBpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, + private val minimumConfig: JsonField, private val modelType: JsonField, private val name: JsonField, private val billableMetricId: JsonField, @@ -54,11 +45,11 @@ private constructor( @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("minimum_config") + @ExcludeMissing + minimumConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonField = JsonMissing.of(), @@ -100,9 +91,9 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkBpsConfig, cadence, itemId, + minimumConfig, modelType, name, billableMetricId, @@ -122,28 +113,32 @@ private constructor( ) /** + * The cadence to bill for this price on. + * * @throws OrbInvalidDataException if 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") /** - * The cadence to bill for this price on. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * 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 itemId(): String = itemId.getRequired("item_id") + 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). */ @@ -273,15 +268,6 @@ private constructor( */ fun referenceId(): Optional = referenceId.getOptional("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]. * @@ -296,6 +282,15 @@ private constructor( */ @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]. * @@ -448,13 +443,14 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewPlanBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionMinimumCompositePrice]. * * The following fields are required: * ```java - * .bulkBpsConfig() * .cadence() * .itemId() + * .minimumConfig() * .modelType() * .name() * ``` @@ -462,12 +458,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanBulkBpsPrice]. */ + /** A builder for [NewSubscriptionMinimumCompositePrice]. */ class Builder internal constructor() { - private var bulkBpsConfig: JsonField? = null 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() @@ -489,39 +485,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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 + 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. */ @@ -546,6 +535,21 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** 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 + } + + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -925,26 +929,26 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanBulkBpsPrice]. + * Returns an immutable instance of [NewSubscriptionMinimumCompositePrice]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .bulkBpsConfig() * .cadence() * .itemId() + * .minimumConfig() * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanBulkBpsPrice = - NewPlanBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), + fun build(): NewSubscriptionMinimumCompositePrice = + NewSubscriptionMinimumCompositePrice( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("minimumConfig", minimumConfig), checkRequired("modelType", modelType), checkRequired("name", name), billableMetricId, @@ -966,14 +970,14 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanBulkBpsPrice = apply { + fun validate(): NewSubscriptionMinimumCompositePrice = apply { if (validated) { return@apply } - bulkBpsConfig().validate() cadence().validate() itemId() + minimumConfig().validate() modelType().validate() name() billableMetricId() @@ -1007,9 +1011,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (minimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (modelType.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -1167,7 +1171,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() @@ -1175,6 +1179,215 @@ private constructor( override fun toString() = value.toString() } + /** 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(): Optional = prorated.getOptional("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: + * ```java + * .minimumAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (prorated.asKnown().isPresent) 1 else 0) + + 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}" + } + + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1189,14 +1402,14 @@ private constructor( companion object { - @JvmField val BULK_BPS = of("bulk_bps") + @JvmField val MINIMUM = of("minimum") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - BULK_BPS + MINIMUM } /** @@ -1209,7 +1422,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BULK_BPS, + MINIMUM, /** * An enum member indicating that [ModelType] was instantiated with an unknown value. */ @@ -1225,7 +1438,7 @@ private constructor( */ fun value(): Value = when (this) { - BULK_BPS -> Value.BULK_BPS + MINIMUM -> Value.MINIMUM else -> Value._UNKNOWN } @@ -1239,7 +1452,7 @@ private constructor( */ fun known(): Known = when (this) { - BULK_BPS -> Known.BULK_BPS + MINIMUM -> Known.MINIMUM else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -1287,7 +1500,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() @@ -1295,184 +1508,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1567,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 @@ -1584,15 +1617,54 @@ 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 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 } - /* 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( + 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() = - "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}" + "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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt index 19f78256..421584a4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -534,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)) /** @@ -556,6 +552,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package pricing */ fun packageConfig(packageConfig: PackageConfig) = packageConfig(JsonField.of(packageConfig)) /** @@ -1168,7 +1165,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() @@ -1176,6 +1173,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1288,7 +1286,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() @@ -1296,184 +1294,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1568,12 +1388,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 @@ -1585,12 +1403,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt index 2fd650c5..3a7339bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionPackageWithAllocationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -544,6 +539,7 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The pricing model type */ fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) /** @@ -566,6 +562,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)) @@ -1179,7 +1176,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() @@ -1187,6 +1184,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1299,7 +1297,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() @@ -1307,16 +1305,90 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for package_with_allocation pricing */ class PackageWithAllocationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1325,6 +1397,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1332,14 +1411,60 @@ 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() @JvmSynthetic 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) @@ -1363,9 +1488,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: + * ```java + * .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 @@ -1375,6 +1514,9 @@ private constructor( return@apply } + allocation() + packageAmount() + packageSize() validated = true } @@ -1394,202 +1536,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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") - } - } - } + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" } /** @@ -1686,12 +1656,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 @@ -1703,12 +1671,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt index fa163926..72135af0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionScalableMatrixWithTieredPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -140,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). */ @@ -154,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). */ @@ -556,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)) /** @@ -578,6 +575,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ fun scalableMatrixWithTieredPricingConfig( scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig ) = @@ -1200,7 +1198,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() @@ -1208,6 +1206,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1321,7 +1320,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,16 +1328,110 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ class ScalableMatrixWithTieredPricingConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = secondDimension.getOptional("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) @@ -1347,6 +1440,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1354,16 +1454,115 @@ 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() @JvmSynthetic 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)) + + /** Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * 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) @@ -1387,9 +1586,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: + * ```java + * .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 @@ -1399,6 +1615,10 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() validated = true } @@ -1418,202 +1638,538 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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(): Optional = + secondDimensionValue.getOptional("second_dimension_value") - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" - } + /** + * 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 - /** 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, - ) { + /** + * 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 - fun unit(): Optional = Optional.ofNullable(unit) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tiered(): Optional = Optional.ofNullable(tiered) + @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: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { - fun isTiered(): Boolean = tiered != null + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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 + } - fun _json(): Optional = Optional.ofNullable(_json) + /** 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a value of - * type [T]. - */ - interface Visitor { + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - fun visitUnit(unit: UnitConversionRateConfig): T + /** + * 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") - fun visitTiered(tiered: TieredConversionRateConfig): T + /** + * 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") /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. + * Returns the raw JSON value of [tierLowerBound]. * - * 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. + * 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]. * - * @throws OrbInvalidDataException in the default implementation. + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) + @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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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) } - return ConversionRateConfig(_json = json) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - } - 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") + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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}" } /** @@ -1710,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 @@ -1727,12 +2281,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt index 9d69516e..3ebc280f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionScalableMatrixWithUnitPricingPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -139,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). */ @@ -153,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). */ @@ -553,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)) /** @@ -575,6 +572,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)) @@ -1192,7 +1190,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() @@ -1200,6 +1198,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1313,7 +1312,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,16 +1320,136 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ class ScalableMatrixWithUnitPricingConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = prorate.getOptional("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(): Optional = secondDimension.getOptional("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) @@ -1339,6 +1458,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1346,16 +1472,125 @@ 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() @JvmSynthetic 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?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * 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) @@ -1379,9 +1614,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: + * ```java + * .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 @@ -1391,6 +1644,11 @@ private constructor( return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + prorate() + secondDimension() validated = true } @@ -1410,202 +1668,320 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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(): Optional = + secondDimensionValue.getOptional("second_dimension_value") - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } + /** + * 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 - /** 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, - ) { + /** + * 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 - fun unit(): Optional = Optional.ofNullable(unit) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tiered(): Optional = Optional.ofNullable(tiered) + @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: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { - fun isTiered(): Boolean = tiered != null + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = matrixScalingFactor.additionalProperties.toMutableMap() + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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 + } - fun _json(): Optional = Optional.ofNullable(_json) + /** 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** @@ -1702,12 +2078,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 @@ -1719,12 +2093,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt index 60f4892e..00ce8f14 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionThresholdTotalAmountPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -544,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)) /** @@ -566,6 +563,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)) @@ -1179,7 +1177,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() @@ -1187,6 +1185,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1299,7 +1298,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() @@ -1307,16 +1306,67 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for threshold_total_amount pricing */ class ThresholdTotalAmountConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = prorate.getOptional("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) @@ -1325,6 +1375,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1332,14 +1387,71 @@ 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() @JvmSynthetic 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?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * 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) @@ -1363,9 +1475,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: + * ```java + * .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 @@ -1375,6 +1498,8 @@ private constructor( return@apply } + consumptionTable().forEach { it.validate() } + prorate() validated = true } @@ -1394,202 +1519,246 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (consumptionTable.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** 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, - ) { + @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: + * ```java + * .threshold() + * .totalAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun unit(): Optional = Optional.ofNullable(unit) + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = consumptionTable.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + /** 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 asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } + private var validated: Boolean = false - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + threshold() + totalAmount() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (totalAmount.asKnown().isPresent) 1 else 0) - 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 ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) } - companion object { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } /** @@ -1686,12 +1855,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 @@ -1703,12 +1870,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt deleted file mode 100644 index 12b70f7c..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPrice.kt +++ /dev/null @@ -1,1716 +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.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 -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = billableMetricId.getOptional("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Optional = billedInAdvance.getOptional("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(): Optional = - billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = - conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = - dimensionalPriceConfiguration.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = - fixedPriceQuantity.getOptional("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(): Optional = - invoiceGroupingKey.getOptional("invoice_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(): Optional = - invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: - * ```java - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredWithProrationConfig() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.billableMetricId] with `billableMetricId.orElse(null)`. */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. 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?) - - /** Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. 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)) - - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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?) - - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. 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: - * ```java - * 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: - * ```java - * 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)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. 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)) - - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. 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)) - - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. 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?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * 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)) - - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = referenceId(referenceId.getOrNull()) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * 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: - * ```java - * .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().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.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. - */ - @JvmSynthetic - internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - 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 { - - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - 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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is 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 */ - } - - /* 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 */ - - 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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt deleted file mode 100644 index cb563c2d..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPrice.kt +++ /dev/null @@ -1,1601 +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.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 -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = billableMetricId.getOptional("billable_metric_id") - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is true, - * and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server - * responded with an unexpected value). - */ - fun billedInAdvance(): Optional = billedInAdvance.getOptional("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(): Optional = - billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = - conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = - dimensionalPriceConfiguration.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = - fixedPriceQuantity.getOptional("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(): Optional = - invoiceGroupingKey.getOptional("invoice_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(): Optional = - invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: - * ```java - * .cadence() - * .itemId() - * .modelType() - * .name() - * .tieredBpsConfig() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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)) - - /** Alias for calling [Builder.billableMetricId] with `billableMetricId.orElse(null)`. */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) - - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] value - * instead. 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?) - - /** Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) - - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] value - * instead. 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)) - - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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?) - - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) - - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) - - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. 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: - * ```java - * 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: - * ```java - * 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)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. 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)) - - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [NewDimensionalPriceConfiguration] value instead. 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)) - - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) - - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. 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?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value - * instead. 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)) - - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. 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)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * 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)) - - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = referenceId(referenceId.getOrNull()) - - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] value instead. - * 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: - * ```java - * .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().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.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. - */ - @JvmSynthetic - internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - 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 { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ModelType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - 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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is 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 */ - } - - /* 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 */ - - 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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt index fb0b2751..5155819b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionTieredPackagePrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -541,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)) /** @@ -563,6 +560,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_package pricing */ fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = tieredPackageConfig(JsonField.of(tieredPackageConfig)) @@ -1176,7 +1174,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() @@ -1184,6 +1182,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1296,7 +1295,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,35 +1303,143 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package pricing */ class TieredPackageConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = 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: + * ```java + * .packageSize() + * .tiers() + * ``` + */ @JvmStatic 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() @JvmSynthetic 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. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1356,9 +1463,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: + * ```java + * .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 @@ -1368,6 +1487,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1387,201 +1508,242 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 - override fun hashCode(): Int = hashCode + /** + * 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 - override fun toString() = "TieredPackageConfig{additionalProperties=$additionalProperties}" - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** 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, - ) { + @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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun unit(): Optional = Optional.ofNullable(unit) + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + /** 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 asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): ConversionRateConfig = 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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } + private var validated: Boolean = false - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + perUnit() + tierLowerBound() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) - 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 Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) } - companion object { + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } - } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } - return ConversionRateConfig(_json = json) - } - } + override fun hashCode(): Int = hashCode - 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") - } - } - } + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -1678,12 +1840,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 @@ -1695,12 +1855,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt index 9ce5883d..07c2cb7d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionTieredPackageWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -139,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). */ @@ -153,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). */ @@ -547,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)) /** @@ -569,6 +566,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)) @@ -1183,7 +1181,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() @@ -1191,6 +1189,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1303,7 +1302,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() @@ -1311,16 +1310,65 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_package_with_minimum pricing */ class TieredPackageWithMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1329,6 +1377,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1336,15 +1390,62 @@ 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() @JvmSynthetic 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) @@ -1368,9 +1469,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: + * ```java + * .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 @@ -1380,6 +1493,8 @@ private constructor( return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -1399,202 +1514,288 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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") - override fun hashCode(): Int = hashCode + /** + * 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 toString() = - "TieredPackageWithMinimumConfig{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 - /** 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, - ) { + /** + * 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 - fun unit(): Optional = Optional.ofNullable(unit) + /** + * 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 tiered(): Optional = Optional.ofNullable(tiered) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isUnit(): Boolean = unit != 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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isTiered(): Boolean = tiered != null + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun _json(): Optional = Optional.ofNullable(_json) + /** 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 accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + minimumAmount() + perUnit() + tierLowerBound() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, perUnit, tierLowerBound, additionalProperties) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } - } + private val hashCode: Int by lazy { Objects.hash(packageSize, tiers, additionalProperties) } - return ConversionRateConfig(_json = json) - } - } + override fun hashCode(): Int = hashCode - 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") - } - } - } + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -1691,12 +1892,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 @@ -1708,12 +1907,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt index 7399c7aa..79610bbc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionTieredPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -533,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)) /** @@ -555,6 +551,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered pricing */ fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) /** @@ -1167,7 +1164,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() @@ -1175,6 +1172,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1287,7 +1285,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() @@ -1295,184 +1293,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1567,12 +1387,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 @@ -1584,12 +1402,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt index 45c1db06..6723b1cd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt @@ -6,22 +6,13 @@ 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.util.Collections @@ -30,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionTieredWithMinimumPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -542,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)) /** @@ -564,6 +561,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)) @@ -1178,7 +1176,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() @@ -1186,6 +1184,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1298,7 +1297,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,16 +1305,84 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for tiered_with_minimum pricing */ class TieredWithMinimumConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = + hideZeroAmountTiers.getOptional("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(): Optional = prorate.getOptional("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) @@ -1323,6 +1390,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1330,13 +1402,75 @@ 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() @JvmSynthetic 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) @@ -1360,9 +1494,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: + * ```java + * .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 @@ -1372,6 +1518,9 @@ private constructor( return@apply } + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() validated = true } @@ -1391,202 +1540,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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") - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * 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 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** 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, - ) { + /** + * 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 unit(): Optional = Optional.ofNullable(unit) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tiered(): Optional = Optional.ofNullable(tiered) + @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: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnit(): Boolean = unit != null + /** A builder for [Tier]. */ + class Builder internal constructor() { - fun isTiered(): Boolean = tiered != null + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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 _json(): Optional = Optional.ofNullable(_json) + /** 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 accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** 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 + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + 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 a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - override fun visitTiered(tiered: TieredConversionRateConfig) = tiered.validity() + private var validated: Boolean = false - override fun unknown(json: JsonValue?) = 0 + fun validate(): Tier = apply { + if (validated) { + return@apply } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + minimumAmount() + tierLowerBound() + unitAmount() + validated = true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - companion object { + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, tierLowerBound, unitAmount, additionalProperties) + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = ConversionRateConfig(tiered = tiered) + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$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") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } /** @@ -1683,12 +1927,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 @@ -1700,12 +1942,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt index 9aa079a0..4d209d5f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionUnitPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -533,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)) /** @@ -555,6 +551,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** @@ -1165,7 +1162,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,6 +1170,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1285,7 +1283,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() @@ -1293,184 +1291,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -1565,12 +1385,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 +1400,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt index 98db611b..fb86e9e2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionUnitWithPercentPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -542,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)) /** @@ -564,6 +560,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)) @@ -1177,7 +1174,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() @@ -1185,6 +1182,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1297,7 +1295,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() @@ -1305,16 +1303,64 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_percent pricing */ class UnitWithPercentConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1322,6 +1368,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithPercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1329,13 +1381,41 @@ 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() @JvmSynthetic 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) @@ -1359,9 +1439,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: + * ```java + * .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 @@ -1371,6 +1463,8 @@ private constructor( return@apply } + percent() + unitAmount() validated = true } @@ -1390,202 +1484,28 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (percent.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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") - } - } - } + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -1682,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 @@ -1699,12 +1617,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-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt index 00565e0f..f41dd44b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt +++ b/orb-java-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 @@ -30,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewSubscriptionUnitWithProrationPrice +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, @@ -138,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). */ @@ -152,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). */ @@ -542,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)) /** @@ -564,6 +560,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)) @@ -1178,7 +1175,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() @@ -1186,6 +1183,7 @@ private constructor( override fun toString() = value.toString() } + /** The pricing model type */ class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1298,7 +1296,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,16 +1304,47 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for unit_with_proration pricing */ class UnitWithProrationConfig - @JsonCreator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -1323,6 +1352,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -1330,13 +1364,27 @@ private constructor( /** A builder for [UnitWithProrationConfig]. */ class Builder internal constructor() { + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic 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) @@ -1360,9 +1408,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: + * ```java + * .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 @@ -1372,6 +1430,7 @@ private constructor( return@apply } + unitAmount() validated = true } @@ -1389,204 +1448,24 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + @JvmSynthetic internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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") - } - } - } + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -1683,12 +1562,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 @@ -1700,12 +1577,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-java-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt index b0151b93..14f9bf6f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt @@ -18,6 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class NewTaxJarConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val taxExempt: JsonField, private val taxProvider: JsonField, @@ -309,7 +310,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() @@ -322,12 +323,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-java-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt index efbcd63f..d4373309 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class NewUsageDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentType: JsonField, private val usageDiscount: JsonField, @@ -666,7 +667,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() @@ -785,7 +786,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() @@ -930,7 +931,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() @@ -943,12 +944,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-java-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt index 7209c4c7..cdb02159 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class OtherSubLineItem +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val grouping: JsonField, @@ -404,7 +405,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() @@ -417,12 +418,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-java-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt index 870228d9..8c89bd5d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt @@ -15,7 +15,9 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections 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, @@ -209,12 +211,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-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt index 74614fee..9b069b6c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PaginationMetadata +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val hasMore: JsonField, private val nextCursor: JsonField, @@ -196,12 +197,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-java-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 8794114c..894da6de 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PerPriceCost +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val price: JsonField, private val priceId: JsonField, @@ -173,27 +174,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.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)) + /** 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)) @@ -201,13 +193,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)`. @@ -241,6 +233,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)`. @@ -255,16 +251,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)) @@ -295,12 +294,14 @@ 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)) + + /** 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 price the cost is associated with */ fun priceId(priceId: String) = priceId(JsonField.of(priceId)) @@ -442,12 +443,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-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt index 8a5befba..0b47ba75 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PercentageDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonField, private val percentageDiscount: JsonField, @@ -472,7 +473,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() @@ -485,12 +486,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-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt index c519de9e..a9a4e07c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt @@ -22,6 +22,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PercentageDiscountInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIntervalIds: JsonField>, private val discountType: JsonField, @@ -525,7 +526,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() @@ -538,12 +539,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-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt index 562bf2a8..ad4f156d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -37,6 +37,7 @@ import kotlin.jvm.optionals.getOrNull * 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>, @@ -1093,27 +1094,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.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)) + /** 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)`. */ @@ -1124,14 +1116,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)`. @@ -1167,6 +1159,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)`. @@ -1181,16 +1177,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)`. */ @@ -1223,12 +1222,14 @@ 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)) + + /** 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)) fun product(product: Product) = product(JsonField.of(product)) @@ -1575,10 +1576,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 { @@ -1714,6 +1721,7 @@ private constructor( } class BasePlan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val externalPlanId: JsonField, @@ -1950,12 +1958,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 @@ -2057,12 +2069,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 @@ -2070,6 +2080,7 @@ private constructor( } class PlanPhase + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val description: JsonField, @@ -2830,7 +2841,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() @@ -2843,12 +2854,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 @@ -2857,6 +2893,7 @@ private constructor( } class Product + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -3072,12 +3109,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 @@ -3207,7 +3248,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() @@ -3216,6 +3257,7 @@ private constructor( } class TrialConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val trialPeriod: JsonField, private val trialPeriodUnit: JsonField, @@ -3525,7 +3567,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() @@ -3538,12 +3580,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 @@ -3556,12 +3601,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-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index c53835e9..211627a7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -584,6 +584,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, @@ -1179,12 +1180,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 @@ -1193,6 +1217,7 @@ private constructor( } class Price + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val planPhaseOrder: JsonField, @@ -1229,7 +1254,7 @@ private constructor( fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("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). @@ -1342,7 +1367,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)) /** Alias for calling [Builder.price] with `price.orElse(null)`. */ @@ -1360,27 +1385,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.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)) + /** 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)`. @@ -1398,9 +1414,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 @@ -1409,11 +1432,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)) /** @@ -1428,6 +1462,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)`. @@ -1444,16 +1484,17 @@ private constructor( /** * Alias for calling [price] with - * `InnerPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + * `InnerPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(InnerPrice.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun price(groupedWithMinMaxThresholds: InnerPrice.GroupedWithMinMaxThresholds) = + price(InnerPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** - * Alias for calling [price] with `InnerPrice.ofBulkWithProration(bulkWithProration)`. + * Alias for calling [price] with + * `InnerPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(InnerPrice.ofBulkWithProration(bulkWithProration)) + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(InnerPrice.ofMatrixWithDisplayName(matrixWithDisplayName)) /** * Alias for calling [price] with @@ -1491,23 +1532,15 @@ 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.ofMinimum(minimum)`. */ + fun price(minimum: NewPlanMinimumCompositePrice) = price(InnerPrice.ofMinimum(minimum)) - /** - * Alias for calling [price] with - * `InnerPrice.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(InnerPrice.ofMatrixWithAllocation(matrixWithAllocation)) + /** Alias for calling [price] with `InnerPrice.ofPercent(percent)`. */ + fun price(percent: InnerPrice.Percent) = price(InnerPrice.ofPercent(percent)) - /** Alias for calling [price] with `InnerPrice.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(InnerPrice.ofGroupedTiered(groupedTiered)) + /** 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() @@ -1570,31 +1603,32 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.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 tieredBps: NewPlanTieredBpsPrice? = null, - private val bps: NewPlanBpsPrice? = null, - private val bulkBps: NewPlanBulkBpsPrice? = 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? = @@ -1603,27 +1637,21 @@ 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 percent: Percent? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) @@ -1634,13 +1662,22 @@ private constructor( fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) fun packageWithAllocation(): Optional = Optional.ofNullable(packageWithAllocation) - fun tieredWithProration(): Optional = + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) fun unitWithProration(): Optional = @@ -1649,18 +1686,21 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) - fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) @@ -1678,30 +1718,21 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + fun percent(): Optional = Optional.ofNullable(percent) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != null + fun isMatrix(): Boolean = matrix != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -1709,23 +1740,31 @@ private constructor( 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 - 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 @@ -1738,27 +1777,21 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isPercent(): Boolean = percent != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isEventOutput(): Boolean = eventOutput != 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 asTieredBps(): NewPlanTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewPlanBpsPrice = bps.getOrThrow("bps") + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") - fun asBulkBps(): NewPlanBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -1769,13 +1802,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 = @@ -1784,18 +1826,21 @@ private constructor( 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 asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = groupedTieredPackage.getOrThrow("groupedTieredPackage") @@ -1811,45 +1856,46 @@ private constructor( fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asMinimum(): NewPlanMinimumCompositePrice = minimum.getOrThrow("minimum") - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asPercent(): Percent = percent.getOrThrow("percent") - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): Optional = Optional.ofNullable(_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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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 -> 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 -> @@ -1862,11 +1908,9 @@ 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) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -1883,32 +1927,20 @@ 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() } - override fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewPlanBpsPrice) { - bps.validate() + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() } - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) { - bulkBps.validate() + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() } override fun visitThresholdTotalAmount( @@ -1927,10 +1959,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( @@ -1939,8 +1975,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() } @@ -1957,6 +2005,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) { @@ -1969,16 +2023,16 @@ private constructor( groupedWithMeteredMinimum.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) { - matrixWithDisplayName.validate() + groupedWithMinMaxThresholds.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) { - bulkWithProration.validate() + matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( @@ -2012,20 +2066,16 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) { + minimum.validate() } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + override fun visitPercent(percent: Percent) { + percent.validate() } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() } } ) @@ -2052,21 +2102,14 @@ 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 visitTieredBps(tieredBps: NewPlanTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewPlanBpsPrice) = bps.validity() + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - override fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice) = bulkBps.validity() + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() override fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice @@ -2079,16 +2122,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( @@ -2099,6 +2153,10 @@ private constructor( groupedAllocation: NewPlanGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -2107,14 +2165,14 @@ private constructor( 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() @@ -2136,16 +2194,13 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + override fun visitMinimum(minimum: NewPlanMinimumCompositePrice) = + minimum.validity() - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + override fun visitPercent(percent: Percent) = percent.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2156,39 +2211,103 @@ 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 */ + return other is InnerPrice && + 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 = /* 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, + 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 -> "InnerPrice{unit=$unit}" - 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}" + 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 -> "InnerPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "InnerPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> "InnerPrice{matrixWithDisplayName=$matrixWithDisplayName}" - bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" groupedTieredPackage != null -> "InnerPrice{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> @@ -2199,11 +2318,9 @@ 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}" + percent != null -> "InnerPrice{percent=$percent}" + eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" _json != null -> "InnerPrice{_unknown=$_json}" else -> throw IllegalStateException("Invalid InnerPrice") } @@ -2212,23 +2329,14 @@ private constructor( @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = InnerPrice(unit = unit) - @JvmStatic - fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = InnerPrice(tiered = tiered) - @JvmStatic - fun ofTieredBps(tieredBps: NewPlanTieredBpsPrice) = - InnerPrice(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: NewPlanBpsPrice) = InnerPrice(bps = bps) + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) @JvmStatic - fun ofBulkBps(bulkBps: NewPlanBulkBpsPrice) = InnerPrice(bulkBps = bulkBps) + fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = @@ -2243,8 +2351,13 @@ private constructor( InnerPrice(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - InnerPrice(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + InnerPrice(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic fun ofPackageWithAllocation( @@ -2252,7 +2365,15 @@ private constructor( ) = InnerPrice(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofTieredWithProration(tieredWithProration: NewPlanTierWithProrationPrice) = + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + InnerPrice(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + InnerPrice(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = InnerPrice(tieredWithProration = tieredWithProration) @JvmStatic @@ -2263,6 +2384,10 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = InnerPrice(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + InnerPrice(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice @@ -2273,15 +2398,16 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ) = InnerPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = InnerPrice(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JvmStatic fun ofMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ) = InnerPrice(matrixWithDisplayName = matrixWithDisplayName) - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - InnerPrice(bulkWithProration = bulkWithProration) - @JvmStatic fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = InnerPrice(groupedTieredPackage = groupedTieredPackage) @@ -2307,17 +2433,12 @@ private constructor( ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofMinimum(minimum: NewPlanMinimumCompositePrice) = InnerPrice(minimum = minimum) - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - InnerPrice(matrixWithAllocation = matrixWithAllocation) + @JvmStatic fun ofPercent(percent: Percent) = InnerPrice(percent = percent) @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - InnerPrice(groupedTiered = groupedTiered) + fun ofEventOutput(eventOutput: EventOutput) = InnerPrice(eventOutput = eventOutput) } /** @@ -2328,19 +2449,13 @@ private constructor( fun visitUnit(unit: NewPlanUnitPrice): T - fun visitPackage(package_: NewPlanPackagePrice): T - - fun visitMatrix(matrix: NewPlanMatrixPrice): T - fun visitTiered(tiered: NewPlanTieredPrice): T - fun visitTieredBps(tieredBps: NewPlanTieredBpsPrice): T - - fun visitBps(bps: NewPlanBpsPrice): T + fun visitBulk(bulk: NewPlanBulkPrice): T - fun visitBulkBps(bulkBps: NewPlanBulkBpsPrice): T + fun visitPackage(package_: NewPlanPackagePrice): T - fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitMatrix(matrix: NewPlanMatrixPrice): T fun visitThresholdTotalAmount( thresholdTotalAmount: NewPlanThresholdTotalAmountPrice @@ -2350,18 +2465,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 @@ -2370,12 +2497,14 @@ private constructor( groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice ): T + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + fun visitMatrixWithDisplayName( matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice ): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - fun visitGroupedTieredPackage( groupedTieredPackage: NewPlanGroupedTieredPackagePrice ): T @@ -2396,15 +2525,11 @@ private constructor( cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice ): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun visitMinimum(minimum: NewPlanMinimumCompositePrice): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun visitPercent(percent: Percent): T - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitEventOutput(eventOutput: EventOutput): T /** * Maps an unknown variant of [InnerPrice] to a value of type [T]. @@ -2434,39 +2559,24 @@ 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) } ?: 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) + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(bulk = it, _json = json) } ?: InnerPrice(_json = json) } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(bulkBps = it, _json = json) } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(package_ = it, _json = json) } ?: InnerPrice(_json = json) } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(bulk = it, _json = json) + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(matrix = it, _json = json) } ?: InnerPrice(_json = json) } "threshold_total_amount" -> { @@ -2482,213 +2592,7176 @@ private constructor( ?.let { InnerPrice(tieredPackage = it, _json = json) } ?: InnerPrice(_json = json) } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(tieredWithMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(tieredWithMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(groupedTiered = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(packageWithAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(unitWithPercent = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(tieredWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(unitWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(bulkWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithProratedMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithMeteredMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithMinMaxThresholds = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(matrixWithDisplayName = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedTieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(maxGroupTieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + InnerPrice(scalableMatrixWithUnitPricing = it, _json = json) + } ?: InnerPrice(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + InnerPrice(scalableMatrixWithTieredPricing = it, _json = json) + } ?: InnerPrice(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(cumulativeGroupedBulk = it, _json = json) } + ?: InnerPrice(_json = json) + } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.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) + } ?: 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.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InnerPrice") + } + } + } + + class 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + 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 + @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, + ) { + + @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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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( + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(unitWithPercent = it, _json = json) } - ?: InnerPrice(_json = json) + + 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(packageWithAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + + /** 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 } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(tieredWithProration = it, _json = json) } - ?: InnerPrice(_json = json) + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(unitWithProration = it, _json = json) } - ?: InnerPrice(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedWithProratedMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedWithMeteredMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(matrixWithDisplayName = it, _json = json) } - ?: InnerPrice(_json = json) + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(bulkWithProration = it, _json = json) } - ?: InnerPrice(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedTieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(maxGroupTieredPackage = it, _json = json) } - ?: InnerPrice(_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 { - InnerPrice(scalableMatrixWithUnitPricing = it, _json = json) - } ?: InnerPrice(_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 { - InnerPrice(scalableMatrixWithTieredPricing = it, _json = json) - } ?: InnerPrice(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(cumulativeGroupedBulk = 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 } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(groupedTiered = it, _json = json) } - ?: InnerPrice(_json = json) + + 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.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 InnerPrice") + 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}" } } @@ -2697,12 +9770,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 @@ -2711,6 +9788,7 @@ private constructor( } class Adjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val planPhaseOrder: JsonField, @@ -3139,10 +10217,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 { @@ -3272,12 +10356,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 @@ -3379,12 +10466,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 @@ -3392,6 +10477,7 @@ private constructor( } class PlanPhase + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val order: JsonField, private val alignBillingWithPhaseStartDate: JsonField, @@ -3822,7 +10908,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() @@ -3835,12 +10921,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 @@ -3968,7 +11065,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() @@ -3981,10 +11078,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-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt index 7753b01f..c4798cbb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt @@ -19,7 +19,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -199,10 +198,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-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt index a1201471..9ecc22e0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt @@ -310,6 +310,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, @@ -500,12 +501,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 @@ -607,12 +611,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 @@ -624,10 +626,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-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt index 63e61d0d..3a893252 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt @@ -15,14 +15,12 @@ import kotlin.jvm.optionals.getOrNull * 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. */ @@ -192,10 +190,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-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt index 8e959d1a..fca69147 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt index c305e49f..e35f1649 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt @@ -134,10 +134,14 @@ private constructor( return true } - return /* spotless:off */ other is PlanListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is PlanListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "PlanListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt index 5a8db213..604bf193 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class PlanListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -216,12 +217,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-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt index 8237f23f..f648c78e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt @@ -412,7 +412,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() @@ -425,10 +425,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-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt index 4ecb20d4..5e43f3bc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PlanPhaseAmountDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -111,7 +112,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 @@ -388,8 +389,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)) @@ -681,7 +682,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() @@ -694,12 +695,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-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt index 66612377..f96eed48 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PlanPhaseMaximumAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -102,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 @@ -368,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)) @@ -678,7 +679,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() @@ -691,12 +692,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-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt index 916a2b0a..219ee76f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PlanPhaseMinimumAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -105,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 @@ -389,8 +390,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)) @@ -714,7 +715,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() @@ -727,12 +728,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-java-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt index 42007ae2..38e2bf4f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PlanPhasePercentageDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -102,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 @@ -373,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)) @@ -684,7 +685,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() @@ -697,12 +698,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-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt index a057996d..e95c6e0a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PlanPhaseUsageDiscountAdjustment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val adjustmentType: JsonField, @@ -102,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 @@ -371,8 +372,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)) @@ -681,7 +682,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() @@ -694,12 +695,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-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt index 278aaf96..f3fce53f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt @@ -302,6 +302,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, @@ -492,12 +493,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 @@ -599,12 +603,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 @@ -616,10 +618,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-java-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index 83256ef3..1e0383de 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -35,6 +35,7 @@ import kotlin.jvm.optionals.getOrNull * plan. */ class PlanVersion +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustments: JsonField>, private val createdAt: JsonField, @@ -310,27 +311,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.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)) + /** 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)`. */ @@ -341,14 +333,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)`. @@ -384,6 +376,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)`. @@ -398,16 +394,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)`. */ @@ -440,12 +439,14 @@ 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)) + + /** 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)) fun version(version: Long) = version(JsonField.of(version)) @@ -683,10 +684,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 { @@ -826,12 +833,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-java-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt index 1d8ad11b..c4c0bdbb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PlanVersionPhase +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val description: JsonField, @@ -490,7 +491,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() @@ -503,12 +504,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-java-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt index 53b0af8a..443eb78d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -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 @@ -48,17 +49,14 @@ import kotlin.jvm.optionals.getOrNull 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 tieredBps: TieredBps? = null, - private val bps: Bps? = null, - private val bulkBps: BulkBps? = 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, @@ -66,44 +64,41 @@ 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 percent: Percent? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) - fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) + fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) + fun tieredPackageWithMinimum(): Optional = Optional.ofNullable(tieredPackageWithMinimum) @@ -122,17 +117,20 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun bulkWithProration(): Optional = Optional.ofNullable(bulkWithProration) - fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) @@ -148,33 +146,30 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun groupedWithMinMaxThresholds(): Optional = - Optional.ofNullable(groupedWithMinMaxThresholds) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun isUnit(): Boolean = unit != null + fun percent(): Optional = Optional.ofNullable(percent) - fun isPackage(): Boolean = package_ != null + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) - fun isMatrix(): Boolean = matrix != null + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != 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 @@ -189,13 +184,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 @@ -207,33 +204,31 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + fun isMinimum(): Boolean = minimum != null - fun asUnit(): Unit = unit.getOrThrow("unit") + fun isPercent(): Boolean = percent != null - fun asPackage(): Package = package_.getOrThrow("package_") + fun isEventOutput(): Boolean = eventOutput != null - fun asMatrix(): Matrix = matrix.getOrThrow("matrix") + fun asUnit(): Unit = unit.getOrThrow("unit") fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - - fun asBps(): Bps = bps.getOrThrow("bps") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") - fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asBulk(): Bulk = bulk.getOrThrow("bulk") + 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") @@ -252,17 +247,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") @@ -278,25 +276,25 @@ private constructor( fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): Optional = Optional.ofNullable(_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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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 -> @@ -306,13 +304,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) @@ -322,8 +322,9 @@ private constructor( visitor.visitScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) cumulativeGroupedBulk != null -> visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -340,32 +341,20 @@ 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() } - override fun visitTieredBps(tieredBps: TieredBps) { - tieredBps.validate() - } - - override fun visitBps(bps: Bps) { - bps.validate() + override fun visitBulk(bulk: Bulk) { + bulk.validate() } - override fun visitBulkBps(bulkBps: BulkBps) { - bulkBps.validate() + override fun visitPackage(package_: Package) { + package_.validate() } - override fun visitBulk(bulk: Bulk) { - bulk.validate() + override fun visitMatrix(matrix: Matrix) { + matrix.validate() } override fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) { @@ -376,14 +365,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 ) { @@ -416,6 +405,10 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: GroupedWithProratedMinimum ) { @@ -428,16 +421,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() } @@ -466,10 +461,16 @@ private constructor( cumulativeGroupedBulk.validate() } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() } } ) @@ -495,19 +496,13 @@ 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 visitTieredBps(tieredBps: TieredBps) = tieredBps.validity() - - override fun visitBps(bps: Bps) = bps.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() - override fun visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitBulk(bulk: Bulk) = bulk.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() override fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = thresholdTotalAmount.validity() @@ -515,12 +510,12 @@ private constructor( 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() @@ -544,6 +539,9 @@ private constructor( override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = groupedAllocation.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: GroupedWithProratedMinimum ) = groupedWithProratedMinimum.validity() @@ -552,13 +550,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() @@ -578,9 +577,11 @@ private constructor( cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + 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,25 +592,82 @@ 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 && + 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 = /* 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, + 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}" - 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}" + 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}" @@ -618,12 +676,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 -> @@ -631,8 +691,9 @@ private constructor( scalableMatrixWithTieredPricing != null -> "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + 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") } @@ -641,19 +702,13 @@ private constructor( @JvmStatic fun ofUnit(unit: Unit) = Price(unit = unit) - @JvmStatic fun ofPackage(package_: Package) = Price(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) - @JvmStatic fun ofTiered(tiered: Tiered) = Price(tiered = tiered) - @JvmStatic fun ofTieredBps(tieredBps: TieredBps) = Price(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: Bps) = Price(bps = bps) + @JvmStatic fun ofBulk(bulk: Bulk) = Price(bulk = bulk) - @JvmStatic fun ofBulkBps(bulkBps: BulkBps) = Price(bulkBps = bulkBps) + @JvmStatic fun ofPackage(package_: Package) = Price(package_ = package_) - @JvmStatic fun ofBulk(bulk: Bulk) = Price(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = @@ -662,13 +717,13 @@ private constructor( @JvmStatic fun ofTieredPackage(tieredPackage: TieredPackage) = Price(tieredPackage = tieredPackage) - @JvmStatic - fun ofGroupedTiered(groupedTiered: GroupedTiered) = Price(groupedTiered = groupedTiered) - @JvmStatic fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = Price(tieredWithMinimum = tieredWithMinimum) + @JvmStatic + fun ofGroupedTiered(groupedTiered: GroupedTiered) = Price(groupedTiered = groupedTiered) + @JvmStatic fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) @@ -697,6 +752,10 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = Price(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + Price(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum(groupedWithProratedMinimum: GroupedWithProratedMinimum) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @@ -706,12 +765,13 @@ private constructor( Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = - Price(matrixWithDisplayName = matrixWithDisplayName) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) @JvmStatic - fun ofBulkWithProration(bulkWithProration: BulkWithProration) = - Price(bulkWithProration = bulkWithProration) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = @@ -735,10 +795,11 @@ private constructor( fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - @JvmStatic - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JvmStatic fun ofMinimum(minimum: Minimum) = Price(minimum = minimum) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** An interface that defines how to map each variant of [Price] to a value of type [T]. */ @@ -746,28 +807,22 @@ private constructor( fun visitUnit(unit: Unit): T - fun visitPackage(package_: Package): T - - fun visitMatrix(matrix: Matrix): T - fun visitTiered(tiered: Tiered): T - fun visitTieredBps(tieredBps: TieredBps): T - - fun visitBps(bps: Bps): T + fun visitBulk(bulk: Bulk): T - fun visitBulkBps(bulkBps: BulkBps): T + fun visitPackage(package_: Package): T - fun visitBulk(bulk: Bulk): 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 @@ -782,15 +837,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 @@ -806,9 +865,11 @@ private constructor( fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun visitMinimum(minimum: Minimum): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -836,39 +897,24 @@ 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) } ?: 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) + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) } ?: Price(_json = json) } - "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkBps = it, _json = json) + "package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(package_ = it, _json = json) } ?: Price(_json = json) } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) } ?: Price(_json = json) } "threshold_total_amount" -> { @@ -881,16 +927,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) @@ -926,6 +972,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) @@ -936,16 +987,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) @@ -971,10 +1022,20 @@ 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) + } ?: 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) } } @@ -991,18 +1052,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.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.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 -> @@ -1014,13 +1072,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 -> @@ -1031,8 +1091,9 @@ 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.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") } @@ -1040,11 +1101,14 @@ private constructor( } class Unit + @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, @@ -1079,7 +1143,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -1141,7 +1211,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -1187,12 +1259,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1253,6 +1338,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -1295,6 +1383,8 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java * JsonValue.from("unit") @@ -1333,6 +1423,8 @@ private constructor( fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). */ @@ -1373,6 +1465,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]. * @@ -1380,6 +1481,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]. * @@ -1601,7 +1712,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -1633,7 +1746,9 @@ 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 private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null @@ -1664,7 +1779,9 @@ 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 conversionRateConfig = unit.conversionRateConfig createdAt = unit.createdAt @@ -1733,6 +1850,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)) /** @@ -1744,6 +1874,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -2040,6 +2205,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)) /** @@ -2226,6 +2395,7 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for unit pricing */ fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) /** @@ -2291,7 +2461,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -2321,7 +2493,11 @@ private constructor( 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), @@ -2358,7 +2534,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -2407,7 +2585,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -2431,7 +2612,7 @@ private constructor( (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -2446,49 +2627,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val CUSTOM = of("custom") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -2502,12 +2668,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -2522,13 +2684,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -2545,7 +2703,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -2575,7 +2733,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -2583,54 +2741,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 tiered(): Optional = Optional.ofNullable(tiered) + companion object { + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") - fun isUnit(): Boolean = unit != null + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun isTiered(): Boolean = tiered != null + @JvmField val ANNUAL = of("annual") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val CUSTOM = of("custom") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun _json(): Optional = Optional.ofNullable(_json) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -2648,121 +2878,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Cadence && value == other.value } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 hashCode() = value.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() = value.toString() } /** @@ -2862,12 +2990,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 @@ -2893,6 +3019,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -2900,6 +3028,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -2914,6 +3043,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -2932,6 +3062,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -2948,6 +3079,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") } @@ -2995,7 +3127,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() @@ -3008,25 +3140,87 @@ 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 && + 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 && + unitConfig == other.unitConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + unitConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 Package + class Tiered + @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, @@ -3044,10 +3238,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, ) { @@ -3061,7 +3255,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -3103,9 +3303,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(), @@ -3115,6 +3312,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 = @@ -3123,7 +3323,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -3141,10 +3343,10 @@ private constructor( minimumAmount, modelType, name, - packageConfig, planPhaseOrder, priceType, replacesPriceId, + tieredConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -3169,12 +3371,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -3235,6 +3450,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -3277,9 +3495,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("package") + * JsonValue.from("tiered") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3293,12 +3513,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). @@ -3320,6 +3534,14 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -3355,6 +3577,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]. * @@ -3362,6 +3593,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]. * @@ -3512,16 +3753,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]. * @@ -3551,6 +3782,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]. * @@ -3577,14 +3818,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -3601,22 +3844,24 @@ private constructor( * .minimum() * .minimumAmount() * .name() - * .packageConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Package]. */ + /** A builder for [Tiered]. */ 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 @@ -3632,45 +3877,47 @@ 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() @JvmSynthetic - internal fun from(package_: Package) = apply { - id = package_.id - billableMetric = package_.billableMetric - billingCycleConfiguration = package_.billingCycleConfiguration - cadence = package_.cadence - 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 + billingMode = tiered.billingMode + 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)) @@ -3716,6 +3963,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)) /** @@ -3727,6 +3987,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -4023,6 +4318,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)) /** @@ -4132,7 +4431,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("package") + * JsonValue.from("tiered") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -4151,20 +4450,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)) @@ -4223,6 +4508,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)) @@ -4266,7 +4565,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. * @@ -4275,7 +4574,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -4292,20 +4593,24 @@ 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), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -4323,10 +4628,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(), ) @@ -4334,7 +4639,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Package = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } @@ -4342,7 +4647,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -4359,15 +4666,15 @@ private constructor( minimum().ifPresent { it.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().ifPresent { it.validate() } validated = true } @@ -4391,7 +4698,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -4407,15 +4717,15 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -4430,49 +4740,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val CUSTOM = of("custom") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -4486,12 +4781,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -4506,13 +4797,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -4529,7 +4816,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -4559,7 +4846,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -4567,54 +4854,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 tiered(): Optional = Optional.ofNullable(tiered) + companion object { - fun isUnit(): Boolean = unit != null + @JvmField val ONE_TIME = of("one_time") - fun isTiered(): Boolean = tiered != null + @JvmField val MONTHLY = of("monthly") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val QUARTERLY = of("quarterly") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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, + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_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) { + 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -4632,121 +4991,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is Cadence && value == other.value } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + override fun hashCode() = value.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() = value.toString() } /** @@ -4846,12 +5103,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 @@ -4877,6 +5132,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -4884,6 +5141,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -4898,6 +5156,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -4916,6 +5175,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -4932,6 +5192,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") } @@ -4979,7 +5240,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() @@ -4992,25 +5253,88 @@ 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 Tiered && + 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 && + tieredConfig == other.tieredConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + tieredConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 Matrix + class Bulk + @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 bulkConfig: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -5021,7 +5345,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, @@ -5045,7 +5368,16 @@ 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(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -5074,9 +5406,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 @@ -5107,7 +5436,10 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, + bulkConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -5118,7 +5450,6 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, - matrixConfig, maximum, maximumAmount, metadata, @@ -5153,12 +5484,33 @@ 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 + * + * @throws OrbInvalidDataException if 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -5219,17 +5571,14 @@ private constructor( invoicingCycleConfiguration.getOptional("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 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). @@ -5267,9 +5616,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("matrix") + * JsonValue.from("bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5339,6 +5690,24 @@ 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]. + * + * 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]. * @@ -5346,6 +5715,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]. * @@ -5440,16 +5819,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]. * @@ -5561,14 +5930,17 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() + * .bulkConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -5579,7 +5951,6 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .matrixConfig() * .maximum() * .maximumAmount() * .metadata() @@ -5594,13 +5965,16 @@ private constructor( @JvmStatic 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 billingMode: 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 @@ -5611,13 +5985,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 @@ -5627,34 +6000,36 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrix: Matrix) = apply { - id = matrix.id - billableMetric = matrix.billableMetric - billingCycleConfiguration = matrix.billingCycleConfiguration - cadence = matrix.cadence - 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 + billingMode = bulk.billingMode + 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)) @@ -5700,6 +6075,33 @@ 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)) + + /** + * 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)) /** @@ -5711,6 +6113,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -6007,6 +6444,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)) /** @@ -6018,19 +6459,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)) @@ -6129,7 +6557,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("matrix") + * JsonValue.from("bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6249,7 +6677,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. * @@ -6258,7 +6686,10 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() + * .bulkConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -6269,7 +6700,6 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .matrixConfig() * .maximum() * .maximumAmount() * .metadata() @@ -6283,12 +6713,17 @@ 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("billingMode", billingMode), + checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -6299,7 +6734,6 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("matrixConfig", matrixConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -6317,7 +6751,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Matrix = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -6325,7 +6759,10 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() + bulkConfig().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -6336,14 +6773,13 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() - matrixConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("matrix")) { + if (it != JsonValue.from("bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -6374,7 +6810,11 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -6385,20 +6825,19 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + - (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -6413,49 +6852,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val CUSTOM = of("custom") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -6469,12 +6893,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -6489,13 +6909,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -6512,7 +6928,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -6542,7 +6958,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -6550,54 +6966,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 tiered(): Optional = Optional.ofNullable(tiered) + companion object { - fun isUnit(): Boolean = unit != null + @JvmField val ONE_TIME = of("one_time") - fun isTiered(): Boolean = tiered != null + @JvmField val MONTHLY = of("monthly") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val QUARTERLY = of("quarterly") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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, + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_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) { + 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -6615,121 +7103,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Cadence && value == other.value } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 hashCode() = value.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() = value.toString() } /** @@ -6829,12 +7215,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 @@ -6860,6 +7244,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -6867,6 +7253,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -6881,6 +7268,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -6899,6 +7287,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -6915,6 +7304,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") } @@ -6962,7 +7352,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() @@ -6975,25 +7365,87 @@ 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 Bulk && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + bulkConfig == other.bulkConfig && + 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 } - /* 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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + bulkConfig, + 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() = - "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}" + "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 Tiered + class Package + @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, @@ -7011,10 +7463,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, ) { @@ -7028,7 +7480,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -7070,6 +7528,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(), @@ -7079,9 +7540,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 = @@ -7090,7 +7548,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -7108,10 +7568,10 @@ private constructor( minimumAmount, modelType, name, + packageConfig, planPhaseOrder, priceType, replacesPriceId, - tieredConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -7136,12 +7596,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -7202,6 +7675,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -7244,9 +7720,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("tiered") + * JsonValue.from("package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7260,6 +7738,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). @@ -7281,12 +7767,6 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -7322,6 +7802,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]. * @@ -7329,6 +7818,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]. * @@ -7479,6 +7978,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]. * @@ -7508,16 +8017,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]. * @@ -7544,14 +8043,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -7568,22 +8069,24 @@ private constructor( * .minimum() * .minimumAmount() * .name() + * .packageConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Tiered]. */ + /** A builder for [Package]. */ 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 @@ -7599,45 +8102,47 @@ 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() @JvmSynthetic - internal fun from(tiered: Tiered) = apply { - id = tiered.id - billableMetric = tiered.billableMetric - billingCycleConfiguration = tiered.billingCycleConfiguration - cadence = tiered.cadence - 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 + billingMode = package_.billingMode + 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)) @@ -7683,6 +8188,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)) /** @@ -7694,6 +8212,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -7990,6 +8543,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)) /** @@ -8099,7 +8656,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("tiered") + * JsonValue.from("package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -8118,6 +8675,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)) @@ -8176,19 +8748,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)) @@ -8232,7 +8791,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. * @@ -8241,7 +8800,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -8258,20 +8819,24 @@ 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), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -8289,10 +8854,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(), ) @@ -8300,7 +8865,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Tiered = apply { + fun validate(): Package = apply { if (validated) { return@apply } @@ -8308,7 +8873,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -8325,15 +8892,15 @@ private constructor( minimum().ifPresent { it.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().ifPresent { it.validate() } validated = true } @@ -8357,7 +8924,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -8373,15 +8943,15 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -8396,49 +8966,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val CUSTOM = of("custom") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -8452,12 +9007,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -8472,13 +9023,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -8495,7 +9042,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -8525,7 +9072,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -8533,54 +9080,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 tiered(): Optional = Optional.ofNullable(tiered) + companion object { - fun isUnit(): Boolean = unit != null + @JvmField val ONE_TIME = of("one_time") - fun isTiered(): Boolean = tiered != null + @JvmField val MONTHLY = of("monthly") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val QUARTERLY = of("quarterly") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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, + } - fun _json(): Optional = Optional.ofNullable(_json) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_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) { + 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -8598,121 +9217,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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") - } + return other is Cadence && value == other.value } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 hashCode() = value.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() = value.toString() } /** @@ -8812,12 +9329,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 @@ -8843,6 +9358,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -8850,6 +9367,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -8864,6 +9382,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -8882,6 +9401,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -8898,6 +9418,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") } @@ -8945,7 +9466,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() @@ -8958,25 +9479,87 @@ 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 Package && + 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 && + packageConfig == other.packageConfig && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + packageConfig, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 TieredBps + class Matrix + @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, @@ -8987,6 +9570,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, @@ -8997,7 +9581,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, ) { @@ -9011,7 +9594,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -9040,6 +9629,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 @@ -9062,9 +9654,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 = @@ -9073,7 +9662,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -9084,6 +9675,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, + matrixConfig, maximum, maximumAmount, metadata, @@ -9094,7 +9686,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredBpsConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -9119,12 +9710,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -9185,11 +9789,22 @@ private constructor( invoicingCycleConfiguration.getOptional("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") + /** + * 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). @@ -9227,9 +9842,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("tiered_bps") + * JsonValue.from("matrix") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -9264,12 +9881,6 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -9305,6 +9916,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]. * @@ -9312,6 +9932,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]. * @@ -9406,6 +10036,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]. * @@ -9491,16 +10131,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]. * @@ -9527,14 +10157,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredBps]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -9545,6 +10177,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .matrixConfig() * .maximum() * .maximumAmount() * .metadata() @@ -9554,19 +10187,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredBpsConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredBps]. */ + /** 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 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 @@ -9577,50 +10211,52 @@ 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("tiered_bps") + private var modelType: JsonValue = JsonValue.from("matrix") 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() @JvmSynthetic - 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(matrix: Matrix) = apply { + id = matrix.id + billableMetric = matrix.billableMetric + billingCycleConfiguration = matrix.billingCycleConfiguration + billingMode = matrix.billingMode + 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)) @@ -9666,6 +10302,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)) /** @@ -9677,6 +10326,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -9973,6 +10657,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)) /** @@ -9984,6 +10672,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)) @@ -10082,7 +10784,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("tiered_bps") + * JsonValue.from("matrix") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -10159,20 +10861,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)) @@ -10216,7 +10904,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredBps]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -10225,7 +10913,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -10236,6 +10926,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .matrixConfig() * .maximum() * .maximumAmount() * .metadata() @@ -10245,17 +10936,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredBpsConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredBps = - TieredBps( + fun build(): Matrix = + Matrix( 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), @@ -10266,6 +10960,7 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("matrixConfig", matrixConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -10276,7 +10971,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredBpsConfig", tieredBpsConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -10284,7 +10978,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredBps = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -10292,7 +10986,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -10303,13 +10999,14 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() + matrixConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered_bps")) { + if (it != JsonValue.from("matrix")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -10317,7 +11014,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredBpsConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -10341,7 +11037,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -10352,20 +11051,20 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -10380,49 +11079,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val MONTHLY = of("monthly") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -10436,12 +11120,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -10456,13 +11136,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -10479,7 +11155,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -10509,7 +11185,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -10517,54 +11193,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ONE_TIME = of("one_time") - fun tiered(): Optional = Optional.ofNullable(tiered) + @JvmField val MONTHLY = of("monthly") - fun isUnit(): Boolean = unit != null + @JvmField val QUARTERLY = of("quarterly") - fun isTiered(): Boolean = tiered != null + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val ANNUAL = of("annual") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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, + } - fun _json(): Optional = Optional.ofNullable(_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) { + 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_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) { + 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -10582,121 +11330,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Cadence && value == other.value } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 hashCode() = value.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() = value.toString() } /** @@ -10796,12 +11442,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 @@ -10827,6 +11471,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -10834,6 +11480,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -10848,6 +11495,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -10866,6 +11514,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -10882,6 +11531,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") } @@ -10929,7 +11579,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() @@ -10942,26 +11592,87 @@ 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 Matrix && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + matrixConfig, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 Bps + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bpsConfig: 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, @@ -10982,6 +11693,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, ) { @@ -10995,10 +11707,13 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bps_config") + @JsonProperty("billing_mode") @ExcludeMissing - bpsConfig: JsonField = JsonMissing.of(), + 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(), @@ -11049,6 +11764,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 = @@ -11057,8 +11775,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bpsConfig, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -11079,6 +11798,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + thresholdTotalAmountConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -11107,7 +11827,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 bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -11115,6 +11835,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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -11175,6 +11902,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -11217,9 +11947,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("bps") + * JsonValue.from("threshold_total_amount") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -11254,6 +11986,15 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). + */ + 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). @@ -11290,13 +12031,13 @@ private constructor( billingCycleConfiguration /** - * Returns the raw JSON value of [bpsConfig]. + * Returns the raw JSON value of [billingMode]. * - * Unlike [bpsConfig], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("bps_config") + @JsonProperty("billing_mode") @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig + fun _billingMode(): JsonField = billingMode /** * Returns the raw JSON value of [cadence]. @@ -11305,6 +12046,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]. * @@ -11484,6 +12235,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]. * @@ -11510,15 +12272,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() - * .bpsConfig() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -11538,19 +12301,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .thresholdTotalAmountConfig() * ``` */ @JvmStatic 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 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 @@ -11566,44 +12331,48 @@ 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() @JvmSynthetic - 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 + billingMode = thresholdTotalAmount.billingMode + 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)) @@ -11649,16 +12418,18 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) /** - * Sets [Builder.bpsConfig] to an arbitrary JSON value. + * Sets [Builder.billingMode] to an arbitrary JSON value. * - * You should usually call [Builder.bpsConfig] with a well-typed [BpsConfig] 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 bpsConfig(bpsConfig: JsonField) = apply { this.bpsConfig = bpsConfig } + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -11671,6 +12442,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -11967,6 +12773,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)) /** @@ -12076,7 +12886,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("bps") + * JsonValue.from("threshold_total_amount") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -12153,6 +12963,21 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a well-typed + * [ThresholdTotalAmountConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -12196,7 +13021,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. * @@ -12205,8 +13030,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bpsConfig() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -12226,17 +13052,21 @@ 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("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -12257,6 +13087,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -12264,7 +13095,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Bps = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } @@ -12272,8 +13103,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - bpsConfig().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -12290,7 +13122,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("bps")) { + if (it != JsonValue.from("threshold_total_amount")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -12298,6 +13130,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + thresholdTotalAmountConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -12321,8 +13154,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -12338,14 +13173,15 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - 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().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -12360,49 +13196,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val CUSTOM = of("custom") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -12416,12 +13237,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -12436,13 +13253,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -12459,7 +13272,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -12489,7 +13302,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -12497,54 +13310,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 tiered(): Optional = Optional.ofNullable(tiered) + companion object { + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") - fun isUnit(): Boolean = unit != null + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun isTiered(): Boolean = tiered != null + @JvmField val ANNUAL = of("annual") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val CUSTOM = of("custom") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun _json(): Optional = Optional.ofNullable(_json) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -12562,121 +13447,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Cadence && value == other.value } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 hashCode() = value.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() = value.toString() } /** @@ -12776,12 +13559,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 @@ -12807,6 +13588,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -12814,6 +13597,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -12828,6 +13612,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -12846,6 +13631,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -12862,6 +13648,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") } @@ -12909,7 +13696,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() @@ -12917,31 +13704,557 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total will be + * charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (consumptionTable.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .threshold() + * .totalAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (threshold.asKnown().isPresent) 1 else 0) + + (if (totalAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { 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 ThresholdTotalAmount && + 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 && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + thresholdTotalAmountConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 BulkBps + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bulkBpsConfig: 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, @@ -12962,6 +14275,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, ) { @@ -12975,10 +14289,13 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bulk_bps_config") + @JsonProperty("billing_mode") @ExcludeMissing - bulkBpsConfig: JsonField = JsonMissing.of(), + 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(), @@ -13029,6 +14346,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 = @@ -13037,8 +14357,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkBpsConfig, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -13059,6 +14380,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + tieredPackageConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -13087,7 +14409,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 bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -13095,6 +14417,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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -13155,6 +14484,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -13197,9 +14529,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("bulk_bps") + * JsonValue.from("tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -13234,6 +14568,15 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). + */ + 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). @@ -13270,14 +14613,13 @@ private constructor( billingCycleConfiguration /** - * Returns the raw JSON value of [bulkBpsConfig]. + * Returns the raw JSON value of [billingMode]. * - * Unlike [bulkBpsConfig], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("bulk_bps_config") + @JsonProperty("billing_mode") @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig + fun _billingMode(): JsonField = billingMode /** * Returns the raw JSON value of [cadence]. @@ -13286,6 +14628,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]. * @@ -13465,6 +14817,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]. * @@ -13491,15 +14853,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkBpsConfig() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -13519,19 +14882,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredPackageConfig() * ``` */ @JvmStatic 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 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 @@ -13547,44 +14912,48 @@ 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() @JvmSynthetic - 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 + billingMode = tieredPackage.billingMode + 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)) @@ -13630,18 +14999,17 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) /** - * Sets [Builder.bulkBpsConfig] to an arbitrary JSON value. + * Sets [Builder.billingMode] 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. + * 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 bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -13655,6 +15023,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -13951,6 +15354,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)) /** @@ -14060,7 +15467,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("bulk_bps") + * JsonValue.from("tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -14137,6 +15544,21 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun tieredPackageConfig(tieredPackageConfig: JsonField) = apply { + this.tieredPackageConfig = tieredPackageConfig + } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -14180,7 +15602,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. * @@ -14189,8 +15611,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkBpsConfig() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -14210,17 +15633,21 @@ 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("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -14241,6 +15668,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired("tieredPackageConfig", tieredPackageConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -14248,7 +15676,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkBps = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } @@ -14256,8 +15684,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - bulkBpsConfig().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -14274,7 +15703,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("bulk_bps")) { + if (it != JsonValue.from("tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -14282,6 +15711,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + tieredPackageConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -14305,8 +15735,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -14322,14 +15754,15 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - 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().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -14344,49 +15777,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val CUSTOM = of("custom") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -14400,12 +15818,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -14420,13 +15834,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -14443,7 +15853,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -14473,7 +15883,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -14481,298 +15891,7 @@ 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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -14787,34 +15906,49 @@ private constructor( companion object { - @JvmField val USAGE_PRICE = of("usage_price") + @JvmField val ONE_TIME = of("one_time") - @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val MONTHLY = of("monthly") - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** An enum containing [PriceType]'s known values. */ + /** An enum containing [Cadence]'s known values. */ enum class Known { - USAGE_PRICE, - FIXED_PRICE, + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, } /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [PriceType] can contain an unknown value in a couple of cases: + * An instance of [Cadence] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may 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, + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. + * An enum member indicating that [Cadence] was instantiated with an unknown value. */ _UNKNOWN, } @@ -14828,8 +15962,12 @@ private constructor( */ fun value(): Value = when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE + 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 } @@ -14844,9 +15982,13 @@ private constructor( */ fun known(): Known = when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") + 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") } /** @@ -14863,7 +16005,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PriceType = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } @@ -14893,7 +16035,7 @@ private constructor( return true } - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is Cadence && value == other.value } override fun hashCode() = value.hashCode() @@ -14901,31 +16043,790 @@ 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * 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. The tier bounds are defined based on the total + * quantity rather than the number of packages, so they must be multiples of the package + * size. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredPackageConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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. The tier bounds are defined based on + * the total quantity rather than the number of packages, so they must be multiples + * of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * 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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { 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 TieredPackage && + 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 && + tieredPackageConfig == other.tieredPackageConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + tieredPackageConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 Bulk + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bulkConfig: 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, @@ -14946,6 +16847,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, ) { @@ -14959,10 +16861,13 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bulk_config") + @JsonProperty("billing_mode") @ExcludeMissing - bulkConfig: JsonField = JsonMissing.of(), + 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(), @@ -15013,6 +16918,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 = @@ -15021,8 +16929,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkConfig, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -15043,6 +16952,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + tieredWithMinimumConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -15071,7 +16981,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 bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -15079,6 +16989,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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -15139,6 +17056,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -15181,9 +17101,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("bulk") + * JsonValue.from("tiered_with_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -15218,6 +17140,15 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -15254,13 +17185,13 @@ private constructor( billingCycleConfiguration /** - * Returns the raw JSON value of [bulkConfig]. + * Returns the raw JSON value of [billingMode]. * - * Unlike [bulkConfig], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("bulk_config") + @JsonProperty("billing_mode") @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig + fun _billingMode(): JsonField = billingMode /** * Returns the raw JSON value of [cadence]. @@ -15269,6 +17200,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]. * @@ -15448,6 +17389,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]. * @@ -15474,15 +17425,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Bulk]. + * Returns a mutable builder for constructing an instance of [TieredWithMinimum]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkConfig() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -15502,19 +17454,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredWithMinimumConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Bulk]. */ + /** 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 bulkConfig: 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 @@ -15530,44 +17484,48 @@ 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("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() @JvmSynthetic - 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(tieredWithMinimum: TieredWithMinimum) = apply { + id = tieredWithMinimum.id + billableMetric = tieredWithMinimum.billableMetric + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + billingMode = tieredWithMinimum.billingMode + 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)) @@ -15613,17 +17571,17 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) /** - * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * Sets [Builder.billingMode] to an arbitrary JSON value. * - * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] 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 bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -15637,6 +17595,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -15933,6 +17926,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)) /** @@ -16042,7 +18039,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("bulk") + * JsonValue.from("tiered_with_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -16119,6 +18116,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)) @@ -16162,7 +18174,7 @@ private constructor( } /** - * Returns an immutable instance of [Bulk]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -16171,8 +18183,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkConfig() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -16192,17 +18205,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Bulk = - Bulk( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkConfig", bulkConfig), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -16223,6 +18240,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -16230,7 +18248,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Bulk = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } @@ -16238,8 +18256,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - bulkConfig().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -16256,7 +18275,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("bulk")) { + if (it != JsonValue.from("tiered_with_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -16264,6 +18283,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + tieredWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -16287,8 +18307,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -16304,13 +18326,143 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -16455,7 +18607,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() @@ -16463,54 +18615,77 @@ 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(): Optional = Optional.ofNullable(unit) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) - fun tiered(): Optional = Optional.ofNullable(tiered) + companion object { - fun isUnit(): Boolean = unit != null + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun isTiered(): Boolean = tiered != null + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + private var additionalProperties: MutableMap = mutableMapOf() - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun _json(): Optional = Optional.ofNullable(_json) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.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(): 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 } @@ -16530,155 +18705,333 @@ private constructor( */ @JvmSynthetic 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - companion object { + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [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. */ - interface Visitor { + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { - fun visitUnit(unit: UnitConversionRateConfig): T + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") - fun visitTiered(tiered: TieredConversionRateConfig): T + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic 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, /** - * 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. + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } + _UNKNOWN, } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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") + } - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - 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) - } - } + private var validated: Boolean = false - return ConversionRateConfig(_json = json) + 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. + */ + @JvmSynthetic internal 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 - @JsonCreator + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = + hideZeroAmountTiers.getOptional("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(): Optional = prorate.getOptional("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: + * ```java + * .tiers() + * ``` + */ @JvmStatic 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() @JvmSynthetic - 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) @@ -16702,20 +19055,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: + * ```java + * .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 } @@ -16735,152 +19104,297 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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) } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the 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 minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - @JvmField val USAGE_PRICE = of("usage_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 + } - @JvmField val FIXED_PRICE = of("fixed_price") + /** 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 + } - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } + /** 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. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * 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 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) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - 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) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $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().orElseThrow { OrbInvalidDataException("Value is not a String") } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - private var validated: Boolean = false + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 + } - fun validate(): PriceType = 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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. - */ - @JvmSynthetic 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 /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + 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 { @@ -16888,25 +19402,87 @@ 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 TieredWithMinimum && + 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 && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + tieredWithMinimumConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 ThresholdTotalAmount + class GroupedTiered + @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, @@ -16915,6 +19491,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, @@ -16927,7 +19504,6 @@ 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, ) { @@ -16941,7 +19517,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -16966,6 +19548,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(), @@ -16992,9 +19577,6 @@ 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 = @@ -17003,7 +19585,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -17012,6 +19596,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -17024,7 +19609,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - thresholdTotalAmountConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -17049,12 +19633,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -17107,6 +19704,15 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("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). @@ -17115,6 +19721,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -17157,9 +19766,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("threshold_total_amount") + * JsonValue.from("grouped_tiered") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -17194,13 +19805,6 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -17236,6 +19840,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]. * @@ -17243,6 +19856,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]. * @@ -17319,6 +19942,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]. * @@ -17422,17 +20055,6 @@ 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]. * @@ -17459,14 +20081,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ThresholdTotalAmount]. + * Returns a mutable builder for constructing an instance of [GroupedTiered]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -17475,6 +20099,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -17486,19 +20111,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .thresholdTotalAmountConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ThresholdTotalAmount]. */ + /** 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 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 @@ -17507,6 +20133,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 @@ -17514,45 +20141,47 @@ 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("grouped_tiered") 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() @JvmSynthetic - 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(groupedTiered: GroupedTiered) = apply { + id = groupedTiered.id + billableMetric = groupedTiered.billableMetric + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + billingMode = groupedTiered.billingMode + 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)) @@ -17598,6 +20227,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)) /** @@ -17609,6 +20251,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -17882,6 +20559,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)) @@ -17905,6 +20597,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)) /** @@ -18014,7 +20710,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("threshold_total_amount") + * JsonValue.from("grouped_tiered") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -18091,20 +20787,6 @@ 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)) @@ -18148,7 +20830,7 @@ private constructor( } /** - * Returns an immutable instance of [ThresholdTotalAmount]. + * Returns an immutable instance of [GroupedTiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -18157,7 +20839,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -18166,6 +20850,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -18177,17 +20862,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .thresholdTotalAmountConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ThresholdTotalAmount = - ThresholdTotalAmount( + fun build(): GroupedTiered = + GroupedTiered( 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), @@ -18196,6 +20884,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedTieredConfig", groupedTieredConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -18208,7 +20897,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -18216,7 +20904,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ThresholdTotalAmount = apply { + fun validate(): GroupedTiered = apply { if (validated) { return@apply } @@ -18224,7 +20912,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -18233,6 +20923,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + groupedTieredConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -18241,7 +20932,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("threshold_total_amount")) { + if (it != JsonValue.from("grouped_tiered")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -18249,7 +20940,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - thresholdTotalAmountConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -18273,7 +20963,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -18282,6 +20975,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -18289,14 +20983,142 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("threshold_total_amount")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -18441,7 +21263,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() @@ -18449,54 +21271,195 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) - fun tiered(): Optional = Optional.ofNullable(tiered) + /** + * 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") - fun isUnit(): Boolean = unit != null + /** + * 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") - fun isTiered(): Boolean = tiered != 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 + + /** + * 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 asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + fun toBuilder() = Builder().from(this) - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + companion object { - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() } - private var validated: Boolean = false + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) - fun validate(): ConversionRateConfig = 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 } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } + /** + * Apply tiered pricing to each segment generated after grouping with the provided + * key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.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() } + } + + /** + * 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: + * ```java + * .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 } @@ -18516,119 +21479,249 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() + /** + * 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 unknown(json: JsonValue?) = 0 - } - ) + /** + * 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 equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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) } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + fun toBuilder() = Builder().from(this) - 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 { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() } - companion object { + /** A builder for [Tier]. */ + class Builder internal constructor() { - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { + /** 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 visitUnit(unit: UnitConversionRateConfig): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitTiered(tiered: TieredConversionRateConfig): T + 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: + * ```java + * .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 + } /** - * 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. + * 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 ConversionRateConfig: $json") + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + override fun hashCode(): Int = hashCode - 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) - } - } + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - return ConversionRateConfig(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - 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") - } - } + 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}" } /** @@ -18728,12 +21821,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 @@ -18759,6 +21850,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -18766,6 +21859,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -18780,6 +21874,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -18798,6 +21893,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -18814,6 +21910,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") } @@ -18861,7 +21958,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() @@ -18869,140 +21966,92 @@ 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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { 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 GroupedTiered && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedTieredConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 TieredPackage + class TieredPackageWithMinimum + @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, @@ -19023,7 +22072,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, ) { @@ -19037,7 +22086,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -19088,9 +22143,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 = @@ -19099,7 +22155,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -19120,7 +22178,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredPackageConfig, + tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -19145,12 +22203,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -19211,6 +22282,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -19253,9 +22327,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * 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 @@ -19291,11 +22367,13 @@ private constructor( fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). */ - 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 @@ -19332,6 +22410,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]. * @@ -19339,6 +22426,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]. * @@ -19519,14 +22616,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]. @@ -19554,14 +22652,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -19581,19 +22681,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredPackageConfig() + * .tieredPackageWithMinimumConfig() * ``` */ @JvmStatic 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 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 @@ -19609,45 +22711,51 @@ 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() @JvmSynthetic - 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 + billingMode = tieredPackageWithMinimum.billingMode + 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)) @@ -19693,6 +22801,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)) /** @@ -19704,6 +22825,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -20000,6 +23156,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)) /** @@ -20109,7 +23269,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("tiered_package") + * JsonValue.from("tiered_package_with_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -20186,19 +23346,21 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) + /** Configuration for tiered_package_with_minimum pricing */ + 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? @@ -20243,7 +23405,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. * @@ -20252,7 +23414,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -20272,17 +23436,21 @@ 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("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -20303,7 +23471,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredPackageConfig", tieredPackageConfig), + checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -20311,7 +23479,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredPackage = apply { + fun validate(): TieredPackageWithMinimum = apply { if (validated) { return@apply } @@ -20319,7 +23487,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -20336,7 +23506,7 @@ private constructor( minimum().ifPresent { it.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") } } @@ -20344,7 +23514,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredPackageConfig().validate() + tieredPackageWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -20368,7 +23538,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -20384,15 +23557,17 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - 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().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -20407,49 +23582,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") - - @JvmField val CUSTOM = of("custom") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -20463,12 +23623,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -20483,13 +23639,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -20506,7 +23658,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -20536,7 +23688,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -20544,54 +23696,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 tiered(): Optional = Optional.ofNullable(tiered) + companion object { - fun isUnit(): Boolean = unit != null + @JvmField val ONE_TIME = of("one_time") - fun isTiered(): Boolean = tiered != null + @JvmField val MONTHLY = of("monthly") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val QUARTERLY = of("quarterly") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val ANNUAL = of("annual") - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -20609,121 +23833,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is Cadence && value == other.value } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + override fun hashCode() = value.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() = value.toString() } /** @@ -20823,12 +23945,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 @@ -20854,6 +23974,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -20861,6 +23983,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -20875,6 +23998,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -20893,6 +24017,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -20909,6 +24034,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") } @@ -20956,7 +24082,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() @@ -20964,35 +24090,145 @@ private constructor( override fun toString() = value.toString() } - class TieredPackageConfig - @JsonCreator + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) companion object { /** - * Returns a mutable builder for constructing an instance of [TieredPackageConfig]. + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredPackageConfig]. */ + /** A builder for [TieredPackageWithMinimumConfig]. */ class Builder internal constructor() { + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = tieredPackageConfig.additionalProperties.toMutableMap() + 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 { @@ -21018,21 +24254,35 @@ 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. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): TieredPackageConfig = apply { + fun validate(): TieredPackageWithMinimumConfig = apply { if (validated) { return@apply } + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -21052,24 +24302,293 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * 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: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -21077,25 +24596,87 @@ 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 TieredPackageWithMinimum && + 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 && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + tieredPackageWithMinimumConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 GroupedTiered + class PackageWithAllocation + @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, @@ -21104,7 +24685,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, @@ -21114,6 +24694,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, @@ -21130,7 +24711,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -21155,9 +24742,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(), @@ -21175,6 +24759,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(), @@ -21192,7 +24779,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -21201,7 +24790,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredConfig, invoicingCycleConfiguration, item, maximum, @@ -21211,6 +24799,7 @@ private constructor( minimumAmount, modelType, name, + packageWithAllocationConfig, planPhaseOrder, priceType, replacesPriceId, @@ -21238,12 +24827,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -21296,13 +24898,6 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("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). @@ -21311,6 +24906,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -21353,9 +24951,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("grouped_tiered") + * JsonValue.from("package_with_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -21369,6 +24969,15 @@ 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). + */ + 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). @@ -21425,6 +25034,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]. * @@ -21432,6 +25050,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]. * @@ -21508,16 +25136,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]. * @@ -21592,6 +25210,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]. * @@ -21647,14 +25276,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -21663,7 +25294,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -21672,6 +25302,7 @@ private constructor( * .minimum() * .minimumAmount() * .name() + * .packageWithAllocationConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() @@ -21680,13 +25311,15 @@ private constructor( @JvmStatic 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 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 @@ -21695,7 +25328,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 @@ -21703,8 +25335,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 @@ -21713,34 +25346,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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 + billingMode = packageWithAllocation.billingMode + 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)) @@ -21786,6 +25422,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)) /** @@ -21797,6 +25446,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -22070,20 +25754,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)) @@ -22107,6 +25777,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)) /** @@ -22216,7 +25890,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_tiered") + * JsonValue.from("package_with_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -22235,6 +25909,22 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a well-typed + * [PackageWithAllocationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -22336,7 +26026,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. * @@ -22345,7 +26035,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -22354,7 +26046,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -22363,6 +26054,7 @@ private constructor( * .minimum() * .minimumAmount() * .name() + * .packageWithAllocationConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() @@ -22370,12 +26062,16 @@ 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("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -22384,7 +26080,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedTieredConfig", groupedTieredConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -22394,6 +26089,7 @@ private constructor( checkRequired("minimumAmount", minimumAmount), modelType, checkRequired("name", name), + checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), @@ -22404,7 +26100,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTiered = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } @@ -22412,7 +26108,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -22421,7 +26119,6 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedTieredConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -22430,11 +26127,12 @@ private constructor( minimum().ifPresent { it.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() @@ -22461,7 +26159,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -22470,7 +26171,6 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -22478,14 +26178,15 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - 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().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -22500,49 +26201,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmField val ANNUAL = of("annual") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -22556,12 +26242,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -22576,13 +26258,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -22599,7 +26277,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -22629,7 +26307,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -22637,54 +26315,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") - fun tiered(): Optional = Optional.ofNullable(tiered) + @JvmField val QUARTERLY = of("quarterly") - fun isUnit(): Boolean = unit != null + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun isTiered(): Boolean = tiered != null + @JvmField val ANNUAL = of("annual") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val CUSTOM = of("custom") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun _json(): Optional = Optional.ofNullable(_json) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -22702,124 +26452,27 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Cadence && value == other.value } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 hashCode() = value.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() = 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 @@ -22834,20 +26487,18 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [GroupedTieredConfig]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedTieredConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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 { @@ -22873,17 +26524,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 } @@ -22914,51 +26564,183 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredConfig && 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 - 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 + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** 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() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + 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 { @@ -22984,20 +26766,38 @@ 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. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): PackageWithAllocationConfig = apply { if (validated) { return@apply } + allocation() + packageAmount() + packageSize() validated = true } @@ -23017,23 +26817,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" } class PriceType @JsonCreator private constructor(private val value: JsonField) : @@ -23055,6 +26862,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -23062,6 +26871,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -23076,6 +26886,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -23094,6 +26905,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -23110,6 +26922,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") } @@ -23157,7 +26970,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() @@ -23170,25 +26983,87 @@ 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 PackageWithAllocation && + 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 && + packageWithAllocationConfig == other.packageWithAllocationConfig && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + packageWithAllocationConfig, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 TieredWithMinimum + class UnitWithPercent + @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, @@ -23209,7 +27084,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, ) { @@ -23223,7 +27098,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -23274,9 +27155,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 = @@ -23285,7 +27166,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -23306,7 +27189,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredWithMinimumConfig, + unitWithPercentConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -23331,12 +27214,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -23397,6 +27293,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -23439,9 +27338,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * 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 @@ -23477,11 +27378,13 @@ private constructor( fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). */ - 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 @@ -23518,6 +27421,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]. * @@ -23525,6 +27437,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]. * @@ -23705,14 +27627,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]. @@ -23740,14 +27662,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -23767,19 +27691,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithMinimumConfig() + * .unitWithPercentConfig() * ``` */ @JvmStatic 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 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 @@ -23795,45 +27721,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_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() @JvmSynthetic - 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 + billingMode = unitWithPercent.billingMode + 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)) @@ -23879,6 +27808,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)) /** @@ -23890,6 +27832,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -24186,6 +28163,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)) /** @@ -24295,7 +28276,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("tiered_with_minimum") + * JsonValue.from("unit_with_percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -24372,19 +28353,21 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + /** Configuration for unit_with_percent pricing */ + 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? @@ -24429,7 +28412,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. * @@ -24438,7 +28421,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -24458,17 +28443,21 @@ 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("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -24489,7 +28478,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -24497,7 +28486,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithMinimum = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } @@ -24505,7 +28494,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -24522,7 +28513,7 @@ private constructor( minimum().ifPresent { it.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") } } @@ -24530,7 +28521,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredWithMinimumConfig().validate() + unitWithPercentConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -24554,7 +28545,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -24570,14 +28564,143 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - 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().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -24722,7 +28845,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() @@ -24730,188 +28853,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -25009,12 +28950,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 @@ -25040,6 +28979,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -25047,6 +28988,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -25061,6 +29003,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -25079,6 +29022,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -25095,6 +29039,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") } @@ -25142,7 +29087,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() @@ -25150,16 +29095,69 @@ private constructor( override fun toString() = value.toString() } - class TieredWithMinimumConfig - @JsonCreator + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -25167,20 +29165,55 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithMinimumConfig]. + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithMinimumConfig]. */ + /** A builder for [UnitWithPercentConfig]. */ class Builder internal constructor() { + private var percent: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() + 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 { @@ -25206,21 +29239,35 @@ 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. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): TieredWithMinimumConfig = apply { + fun validate(): UnitWithPercentConfig = apply { if (validated) { return@apply } + percent() + unitAmount() validated = true } @@ -25240,24 +29287,28 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (percent.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -25265,25 +29316,87 @@ 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 UnitWithPercent && + 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 && + unitWithPercentConfig == other.unitWithPercentConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + unitWithPercentConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 TieredPackageWithMinimum + class MatrixWithAllocation + @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, @@ -25294,6 +29407,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, @@ -25304,7 +29418,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, ) { @@ -25318,7 +29431,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -25347,6 +29466,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 @@ -25369,10 +29491,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 = @@ -25381,7 +29499,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -25392,6 +29512,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, + matrixWithAllocationConfig, maximum, maximumAmount, metadata, @@ -25402,7 +29523,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -25427,12 +29547,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -25493,11 +29626,23 @@ private constructor( invoicingCycleConfiguration.getOptional("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") + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -25535,9 +29680,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * 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 @@ -25572,13 +29719,6 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -25614,6 +29754,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]. * @@ -25621,6 +29770,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]. * @@ -25715,6 +29874,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]. * @@ -25800,17 +29970,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]. * @@ -25837,14 +29996,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -25855,6 +30016,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .matrixWithAllocationConfig() * .maximum() * .maximumAmount() * .metadata() @@ -25864,19 +30026,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredPackageWithMinimumConfig() * ``` */ @JvmStatic 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 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 @@ -25887,53 +30050,53 @@ 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() @JvmSynthetic - 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 + billingMode = matrixWithAllocation.billingMode + 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)) @@ -25979,6 +30142,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)) /** @@ -25990,6 +30166,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -26286,6 +30497,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)) /** @@ -26297,6 +30512,21 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = + matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a well-typed + * [MatrixWithAllocationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -26395,7 +30625,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * 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 @@ -26472,21 +30702,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)) @@ -26530,7 +30745,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. * @@ -26539,7 +30754,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -26550,6 +30767,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .matrixWithAllocationConfig() * .maximum() * .maximumAmount() * .metadata() @@ -26559,17 +30777,20 @@ 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("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -26580,6 +30801,7 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -26590,7 +30812,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -26598,7 +30819,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredPackageWithMinimum = apply { + fun validate(): MatrixWithAllocation = apply { if (validated) { return@apply } @@ -26606,7 +30827,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -26617,13 +30840,14 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() + matrixWithAllocationConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.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") } } @@ -26631,7 +30855,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredPackageWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -26655,7 +30878,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -26666,22 +30892,20 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.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().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -26696,49 +30920,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val MONTHLY = of("monthly") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -26752,12 +30961,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -26772,13 +30977,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -26795,7 +30996,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -26825,7 +31026,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -26833,54 +31034,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 tiered(): Optional = Optional.ofNullable(tiered) + companion object { - fun isUnit(): Boolean = unit != null + @JvmField val ONE_TIME = of("one_time") - fun isTiered(): Boolean = tiered != null + @JvmField val MONTHLY = of("monthly") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun _json(): Optional = Optional.ofNullable(_json) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -26898,121 +31171,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Cadence && value == other.value } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 hashCode() = value.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() = value.toString() } /** @@ -27112,12 +31283,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 @@ -27143,6 +31312,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -27150,6 +31321,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -27164,6 +31336,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -27182,6 +31355,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -27198,6 +31372,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") } @@ -27245,7 +31420,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() @@ -27253,141 +31428,92 @@ 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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { 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 MatrixWithAllocation && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + matrixWithAllocationConfig, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 PackageWithAllocation + class TieredWithProration + @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, @@ -27405,10 +31531,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, ) { @@ -27422,7 +31548,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -27464,9 +31596,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(), @@ -27476,6 +31605,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 = @@ -27484,7 +31616,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -27502,10 +31636,10 @@ private constructor( minimumAmount, modelType, name, - packageWithAllocationConfig, planPhaseOrder, priceType, replacesPriceId, + tieredWithProrationConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -27530,12 +31664,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -27596,6 +31743,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -27638,9 +31788,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * 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 @@ -27654,13 +31806,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). @@ -27682,6 +31827,15 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). + */ + 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). @@ -27717,6 +31871,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]. * @@ -27724,6 +31887,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]. * @@ -27874,17 +32047,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]. * @@ -27914,6 +32076,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]. * @@ -27940,14 +32113,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -27964,22 +32139,24 @@ private constructor( * .minimum() * .minimumAmount() * .name() - * .packageWithAllocationConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .tieredWithProrationConfig() * ``` */ @JvmStatic 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 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 @@ -27995,45 +32172,48 @@ 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() @JvmSynthetic - 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 + billingMode = tieredWithProration.billingMode + 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)) @@ -28079,6 +32259,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)) /** @@ -28090,6 +32283,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -28386,6 +32614,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)) /** @@ -28495,7 +32727,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("package_with_allocation") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -28514,21 +32746,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)) @@ -28587,6 +32804,21 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** 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 } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -28630,7 +32862,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. * @@ -28639,7 +32871,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -28656,20 +32890,24 @@ 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("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -28687,10 +32925,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(), ) @@ -28698,7 +32936,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PackageWithAllocation = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } @@ -28706,7 +32944,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -28723,15 +32963,15 @@ private constructor( minimum().ifPresent { it.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().ifPresent { it.validate() } validated = true } @@ -28755,7 +32995,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -28771,15 +33014,15 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - 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().isPresent) 1 else 0) + - (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -28794,49 +33037,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val ANNUAL = of("annual") - - @JvmField val CUSTOM = of("custom") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -28850,12 +33078,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -28870,13 +33094,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -28893,7 +33113,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -28923,7 +33143,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -28931,54 +33151,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") - fun unit(): Optional = Optional.ofNullable(unit) + @JvmField val QUARTERLY = of("quarterly") - fun tiered(): Optional = Optional.ofNullable(tiered) + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun isUnit(): Boolean = unit != null + @JvmField val ANNUAL = of("annual") - fun isTiered(): Boolean = tiered != null + @JvmField val CUSTOM = of("custom") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** 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, + } - fun _json(): Optional = Optional.ofNullable(_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) { + 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_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) { + 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -28996,121 +33288,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is Cadence && value == other.value } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + override fun hashCode() = value.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() = value.toString() } /** @@ -29210,28 +33400,192 @@ 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 override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - class PackageWithAllocationConfig - @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 { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && 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( - @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) @@ -29239,22 +33593,57 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PackageWithAllocationConfig]. + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [PackageWithAllocationConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = - apply { - additionalProperties = - packageWithAllocationConfig.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) = apply { this.additionalProperties.clear() @@ -29279,21 +33668,32 @@ private constructor( } /** - * Returns an immutable instance of [PackageWithAllocationConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): PackageWithAllocationConfig = apply { + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } + tiers().forEach { it.validate() } validated = true } @@ -29313,153 +33713,245 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (tiers.asKnown().getOrNull()?.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()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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) } - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the 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 tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - @JvmField val USAGE_PRICE = of("usage_price") + /** 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 + } - @JvmField val FIXED_PRICE = of("fixed_price") + /** 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 + } - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * 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 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) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - 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) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") + 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: + * ```java + * .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 } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) - fun validate(): PriceType = 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. - */ - @JvmSynthetic 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 /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + 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}" } override fun equals(other: Any?): Boolean { @@ -29467,25 +33959,87 @@ 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 TieredWithProration && + 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 && + tieredWithProrationConfig == other.tieredWithProrationConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + tieredWithProrationConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 UnitWithPercent + class UnitWithProration + @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, @@ -29506,7 +34060,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, ) { @@ -29520,7 +34074,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -29571,9 +34131,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 = @@ -29582,7 +34142,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -29603,7 +34165,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - unitWithPercentConfig, + unitWithProrationConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -29628,12 +34190,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -29694,6 +34269,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -29736,9 +34314,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * 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 @@ -29774,11 +34354,13 @@ private constructor( fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). */ - 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 @@ -29815,6 +34397,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]. * @@ -29822,6 +34413,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]. * @@ -30002,14 +34603,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]. @@ -30037,14 +34638,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -30064,19 +34667,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .unitWithPercentConfig() + * .unitWithProrationConfig() * ``` */ @JvmStatic 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 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 @@ -30092,45 +34697,48 @@ 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() @JvmSynthetic - 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 + billingMode = unitWithProration.billingMode + 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)) @@ -30176,6 +34784,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)) /** @@ -30187,6 +34808,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -30483,6 +35139,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)) /** @@ -30592,7 +35252,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("unit_with_percent") + * JsonValue.from("unit_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -30669,20 +35329,20 @@ private constructor( this.replacesPriceId = replacesPriceId } - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + /** Configuration for unit_with_proration pricing */ + 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? @@ -30727,7 +35387,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. * @@ -30736,7 +35396,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -30756,17 +35418,21 @@ 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("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -30787,7 +35453,7 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -30795,7 +35461,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitWithPercent = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } @@ -30803,7 +35469,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -30820,7 +35488,7 @@ private constructor( minimum().ifPresent { it.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") } } @@ -30828,7 +35496,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - unitWithPercentConfig().validate() + unitWithProrationConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -30852,7 +35520,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -30868,15 +35539,15 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - 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().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -30891,49 +35562,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val MONTHLY = of("monthly") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -30947,12 +35603,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -30967,13 +35619,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -30990,7 +35638,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -31020,7 +35668,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -31028,54 +35676,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then 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 unit(): Optional = Optional.ofNullable(unit) + @JvmField val ONE_TIME = of("one_time") - fun tiered(): Optional = Optional.ofNullable(tiered) + @JvmField val MONTHLY = of("monthly") - fun isUnit(): Boolean = unit != null + @JvmField val QUARTERLY = of("quarterly") - fun isTiered(): Boolean = tiered != null + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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, + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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, + } - fun _json(): Optional = Optional.ofNullable(_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) { + 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 + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_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) { + 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -31093,121 +35813,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } + return other is Cadence && value == other.value } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + override fun hashCode() = value.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() = value.toString() } /** @@ -31307,12 +35925,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 @@ -31338,6 +35954,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -31345,6 +35963,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -31359,6 +35978,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -31377,6 +35997,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -31393,6 +36014,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") } @@ -31440,7 +36062,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() @@ -31448,16 +36070,49 @@ private constructor( override fun toString() = value.toString() } - class UnitWithPercentConfig - @JsonCreator + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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) @@ -31465,19 +36120,41 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UnitWithPercentConfig]. + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnitWithPercentConfig]. */ + /** A builder for [UnitWithProrationConfig]. */ class Builder internal constructor() { + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = unitWithPercentConfig.additionalProperties.toMutableMap() + 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 { @@ -31503,21 +36180,32 @@ 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. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): UnitWithPercentConfig = apply { + fun validate(): UnitWithProrationConfig = apply { if (validated) { return@apply } + unitAmount() validated = true } @@ -31536,25 +36224,24 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -31562,25 +36249,87 @@ 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 UnitWithProration && + 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 && + unitWithProrationConfig == other.unitWithProrationConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + unitWithProrationConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 MatrixWithAllocation + class GroupedAllocation + @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, @@ -31589,9 +36338,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, @@ -31615,7 +36364,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -31640,13 +36395,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 @@ -31677,7 +36432,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -31686,9 +36443,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedAllocationConfig, invoicingCycleConfiguration, item, - matrixWithAllocationConfig, maximum, maximumAmount, metadata, @@ -31723,12 +36480,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -31781,6 +36551,15 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("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). + */ + 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). @@ -31789,18 +36568,14 @@ private constructor( invoicingCycleConfiguration.getOptional("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 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). @@ -31838,9 +36613,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("matrix_with_allocation") + * JsonValue.from("grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -31910,6 +36687,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]. * @@ -31917,6 +36703,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]. * @@ -31993,6 +36789,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]. * @@ -32011,17 +36817,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]. * @@ -32133,14 +36928,16 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -32149,9 +36946,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedAllocationConfig() * .invoicingCycleConfiguration() * .item() - * .matrixWithAllocationConfig() * .maximum() * .maximumAmount() * .metadata() @@ -32166,13 +36963,15 @@ private constructor( @JvmStatic 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 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 @@ -32181,15 +36980,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 @@ -32199,34 +36998,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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 + billingMode = groupedAllocation.billingMode + 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)) @@ -32272,6 +37074,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)) /** @@ -32283,6 +37098,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -32556,6 +37406,21 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -32579,6 +37444,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)) /** @@ -32590,20 +37459,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)) @@ -32702,7 +37557,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("matrix_with_allocation") + * JsonValue.from("grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -32822,7 +37677,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. * @@ -32831,7 +37686,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -32840,9 +37697,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedAllocationConfig() * .invoicingCycleConfiguration() * .item() - * .matrixWithAllocationConfig() * .maximum() * .maximumAmount() * .metadata() @@ -32856,12 +37713,16 @@ 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("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -32870,9 +37731,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), @@ -32890,7 +37751,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixWithAllocation = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -32898,7 +37759,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -32907,16 +37770,16 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + groupedAllocationConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() - matrixWithAllocationConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("matrix_with_allocation")) { + if (it != JsonValue.from("grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -32947,7 +37810,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -32956,21 +37822,150 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + - (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.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().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -33115,7 +38110,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() @@ -33123,54 +38118,229 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } - fun isTiered(): Boolean = tiered != null + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** How to determine the groups that should each be allocated some quantity */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false - fun validate(): 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() - } - } - ) + allocation() + groupingKey() + overageUnitRate() validated = true } @@ -33190,119 +38360,30 @@ private constructor( */ @JvmSynthetic 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 - } - ) + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 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{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" } /** @@ -33402,12 +38483,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 @@ -33433,6 +38512,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -33440,6 +38521,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -33454,6 +38536,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -33472,6 +38555,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -33488,6 +38572,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") } @@ -33535,7 +38620,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() @@ -33548,25 +38633,88 @@ 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 GroupedAllocation && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedAllocationConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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, 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 TieredWithProration + class BulkWithProration + @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 bulkWithProrationConfig: JsonField, private val cadence: JsonField, + private val compositePriceFilters: JsonField>, private val conversionRate: JsonField, private val conversionRateConfig: JsonField, private val createdAt: JsonField, @@ -33587,7 +38735,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, ) { @@ -33601,7 +38748,16 @@ 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(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -33652,9 +38808,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 = @@ -33663,7 +38816,10 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, + bulkWithProrationConfig, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -33684,7 +38840,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredWithProrationConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -33709,12 +38864,34 @@ 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 + * + * @throws OrbInvalidDataException if 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -33775,6 +38952,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -33817,9 +38997,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -33854,13 +39036,6 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -33896,6 +39071,25 @@ 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]. + * + * 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]. * @@ -33903,6 +39097,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]. * @@ -34082,17 +39286,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]. * @@ -34119,14 +39312,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [BulkWithProration]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() + * .bulkWithProrationConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -34146,19 +39342,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** 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 billingMode: 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 @@ -34174,45 +39372,47 @@ 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("bulk_with_proration") 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() @JvmSynthetic - 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(bulkWithProration: BulkWithProration) = apply { + id = bulkWithProration.id + billableMetric = bulkWithProration.billableMetric + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + billingMode = bulkWithProration.billingMode + 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)) @@ -34258,6 +39458,34 @@ 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)) + + /** + * 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)) /** @@ -34269,6 +39497,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -34565,6 +39828,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)) /** @@ -34674,7 +39941,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -34751,20 +40018,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)) @@ -34808,7 +40061,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -34817,7 +40070,10 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() + * .bulkWithProrationConfig() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -34837,17 +40093,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -34868,7 +40128,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -34876,7 +40135,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -34884,7 +40143,10 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() + bulkWithProrationConfig().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -34901,7 +40163,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("bulk_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -34909,7 +40171,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredWithProrationConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -34933,7 +40194,11 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -34949,14 +40214,552 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("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: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -35101,7 +40904,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() @@ -35109,188 +40912,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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 @@ -35388,12 +41009,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 @@ -35419,6 +41038,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -35426,6 +41047,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -35440,6 +41062,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -35458,6 +41081,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -35474,6 +41098,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") } @@ -35521,7 +41146,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() @@ -35529,140 +41154,92 @@ 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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { 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 BulkWithProration && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + bulkWithProrationConfig == other.bulkWithProrationConfig && + 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 } - /* 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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + bulkWithProrationConfig, + 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() = - "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}" + "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 UnitWithProration + class GroupedWithProratedMinimum + @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, @@ -35671,6 +41248,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, @@ -35683,7 +41261,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, ) { @@ -35697,7 +41274,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -35722,6 +41305,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(), @@ -35748,9 +41335,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 = @@ -35759,7 +41343,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -35768,6 +41354,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -35780,7 +41367,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - unitWithProrationConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -35805,12 +41391,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -35863,6 +41462,15 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("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 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). @@ -35871,6 +41479,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -35913,9 +41524,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("unit_with_proration") + * JsonValue.from("grouped_with_prorated_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -35950,13 +41563,6 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -35992,6 +41598,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]. * @@ -35999,6 +41614,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]. * @@ -36075,6 +41700,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]. * @@ -36178,16 +41814,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]. * @@ -36214,14 +41840,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnitWithProration]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -36230,6 +41859,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -36241,19 +41871,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .unitWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnitWithProration]. */ + /** 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 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 @@ -36262,6 +41893,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 @@ -36269,45 +41903,50 @@ 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_prorated_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() @JvmSynthetic - 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(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { + id = groupedWithProratedMinimum.id + billableMetric = groupedWithProratedMinimum.billableMetric + billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration + billingMode = groupedWithProratedMinimum.billingMode + 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)) @@ -36353,6 +41992,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)) /** @@ -36364,6 +42016,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -36637,6 +42324,22 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a well-typed + * [GroupedWithProratedMinimumConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -36660,6 +42363,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)) /** @@ -36769,7 +42476,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("unit_with_proration") + * JsonValue.from("grouped_with_prorated_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -36846,20 +42553,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)) @@ -36903,7 +42596,7 @@ private constructor( } /** - * Returns an immutable instance of [UnitWithProration]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -36912,7 +42605,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -36921,6 +42616,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedWithProratedMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -36932,17 +42628,20 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnitWithProration = - UnitWithProration( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( 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), @@ -36951,6 +42650,10 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -36963,7 +42666,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -36971,7 +42673,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitWithProration = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -36979,7 +42681,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -36988,6 +42692,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + groupedWithProratedMinimumConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -36996,7 +42701,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("unit_with_proration")) { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -37004,7 +42709,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - unitWithProrationConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -37028,7 +42732,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -37037,6 +42744,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -37044,14 +42752,144 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("unit_with_proration")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -37196,7 +43034,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() @@ -37204,54 +43042,221 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) + @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()) - fun tiered(): Optional = Optional.ofNullable(tiered) + /** + * 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") - fun isUnit(): Boolean = unit != null + /** + * 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") - fun isTiered(): Boolean = tiered != null + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_rate") @ExcludeMissing fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { this.unitRate = unitRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun 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(): Optional = Optional.ofNullable(_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 [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): GroupedWithProratedMinimumConfig = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + groupingKey() + minimum() + unitRate() validated = true } @@ -37271,119 +43276,30 @@ private constructor( */ @JvmSynthetic 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 - } - ) + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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(groupingKey, minimum, unitRate, 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() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" } /** @@ -37483,12 +43399,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 @@ -37514,6 +43428,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -37521,6 +43437,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -37535,6 +43452,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -37553,6 +43471,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -37569,6 +43488,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") } @@ -37616,7 +43536,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() @@ -37624,140 +43544,92 @@ 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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { 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 GroupedWithProratedMinimum && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedWithProratedMinimumConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 GroupedAllocation + class GroupedWithMeteredMinimum + @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, @@ -37766,7 +43638,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedAllocationConfig: JsonField, + private val groupedWithMeteredMinimumConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -37792,7 +43664,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -37817,9 +43695,10 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") + @JsonProperty("grouped_with_metered_minimum_config") @ExcludeMissing - groupedAllocationConfig: JsonField = JsonMissing.of(), + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -37854,7 +43733,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -37863,7 +43744,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedAllocationConfig, + groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, maximum, @@ -37900,12 +43781,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -37959,11 +43853,13 @@ private constructor( fixedPriceQuantity.getOptional("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 groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -37973,6 +43869,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -38015,9 +43914,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("grouped_allocation") + * JsonValue.from("grouped_with_metered_minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -38087,6 +43988,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]. * @@ -38094,6 +44004,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]. * @@ -38171,14 +44091,15 @@ private constructor( fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** - * Returns the raw JSON value of [groupedAllocationConfig]. + * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. * - * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("grouped_allocation_config") + @JsonProperty("grouped_with_metered_minimum_config") @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = groupedAllocationConfig + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig /** * Returns the raw JSON value of [invoicingCycleConfiguration]. @@ -38309,14 +44230,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedAllocation]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -38325,7 +44249,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedAllocationConfig() + * .groupedWithMeteredMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -38342,13 +44266,15 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedAllocation]. */ + /** 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 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 @@ -38357,7 +44283,9 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedAllocationConfig: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -38365,7 +44293,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_allocation") + 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 @@ -38375,34 +44303,39 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { + id = groupedWithMeteredMinimum.id + billableMetric = groupedWithMeteredMinimum.billableMetric + billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration + billingMode = groupedWithMeteredMinimum.billingMode + 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)) @@ -38448,6 +44381,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)) /** @@ -38459,6 +44405,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -38732,19 +44713,21 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) /** - * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * Sets [Builder.groupedWithMeteredMinimumConfig] 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. + * 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 groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? @@ -38769,6 +44752,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)) /** @@ -38878,7 +44865,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_allocation") + * JsonValue.from("grouped_with_metered_minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -38998,7 +44985,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedAllocation]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -39007,7 +44994,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -39016,7 +45005,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedAllocationConfig() + * .groupedWithMeteredMinimumConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -39032,12 +45021,16 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedAllocation = - GroupedAllocation( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( 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), @@ -39046,7 +45039,10 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -39066,7 +45062,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedAllocation = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -39074,7 +45070,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -39083,7 +45081,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedAllocationConfig().validate() + groupedWithMeteredMinimumConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -39092,7 +45090,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_allocation")) { + if (it != JsonValue.from("grouped_with_metered_minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -39123,7 +45121,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -39132,7 +45133,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -39140,13 +45141,144 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -39291,7 +45423,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() @@ -39299,219 +45431,338 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + 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, ) { - fun unit(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(tiered) - - fun isUnit(): Boolean = unit != null - - fun isTiered(): Boolean = tiered != null - - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @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(), + ) - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** + * 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") - fun _json(): Optional = Optional.ofNullable(_json) + /** + * 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") - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) - } + /** + * 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") - private var validated: Boolean = false + /** + * 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") - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply - } + /** + * 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") - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } + /** + * 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") - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) - validated = true - } + /** + * 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 isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * 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 a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [pricingKey]. * - * Used for best match union deserialization. + * Unlike [pricingKey], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() + /** + * 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 - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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 - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(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") - } + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { - fun visitUnit(unit: UnitConversionRateConfig): T + 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() + + @JvmSynthetic + 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() + } - fun visitTiered(tiered: TieredConversionRateConfig): T + /** + * Used to partition the usage into groups. The minimum amount is applied to each + * group. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * 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. + * 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 unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - } - - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) - 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) + /** + * 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 } - } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) - 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") - } + /** + * 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 } - } - } - class GroupedAllocationConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * 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() } + } - fun toBuilder() = Builder().from(this) + /** + * 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) + } + } - companion object { + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) /** - * Returns a mutable builder for constructing an instance of - * [GroupedAllocationConfig]. + * 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. */ - @JvmStatic fun builder() = Builder() - } + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any + * unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) - private var additionalProperties: MutableMap = mutableMapOf() + /** + * 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() } + } - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() + /** + * 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 { @@ -39537,21 +45788,47 @@ private constructor( } /** - * Returns an immutable instance of [GroupedAllocationConfig]. + * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(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(): GroupedAllocationConfig = apply { + fun validate(): GroupedWithMeteredMinimumConfig = apply { if (validated) { return@apply } + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } validated = true } @@ -39571,24 +45848,487 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * 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: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * 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: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } /** @@ -39688,12 +46428,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 @@ -39719,6 +46457,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -39726,6 +46466,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -39740,6 +46481,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -39758,6 +46500,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -39774,6 +46517,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") } @@ -39821,7 +46565,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() @@ -39834,25 +46578,87 @@ 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 GroupedWithMeteredMinimum && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedWithMeteredMinimumConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 GroupedWithProratedMinimum + class GroupedWithMinMaxThresholds + @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, @@ -39861,7 +46667,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithProratedMinimumConfig: JsonField, + private val groupedWithMinMaxThresholdsConfig: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -39887,7 +46693,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -39912,9 +46724,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - groupedWithProratedMinimumConfig: JsonField = + groupedWithMinMaxThresholdsConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing @@ -39950,7 +46762,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -39959,7 +46773,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithProratedMinimumConfig, + groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -39996,12 +46810,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -40055,11 +46882,13 @@ private constructor( fixedPriceQuantity.getOptional("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 groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + 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 @@ -40069,6 +46898,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -40111,9 +46943,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_prorated_minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -40183,6 +47017,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]. * @@ -40190,6 +47033,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]. * @@ -40267,15 +47120,15 @@ private constructor( fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** - * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON field + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("grouped_with_prorated_minimum_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): JsonField = - groupedWithProratedMinimumConfig + fun _groupedWithMinMaxThresholdsConfig(): JsonField = + groupedWithMinMaxThresholdsConfig /** * Returns the raw JSON value of [invoicingCycleConfiguration]. @@ -40407,14 +47260,16 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithProratedMinimum]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -40423,7 +47278,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithProratedMinimumConfig() + * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -40440,13 +47295,15 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithProratedMinimum]. */ + /** 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 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 @@ -40455,8 +47312,8 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = + private var groupedWithMinMaxThresholdsConfig: + JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null @@ -40465,7 +47322,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("grouped_with_min_max_thresholds") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -40475,37 +47332,41 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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 + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { + id = groupedWithMinMaxThresholds.id + billableMetric = groupedWithMinMaxThresholds.billableMetric + billingCycleConfiguration = groupedWithMinMaxThresholds.billingCycleConfiguration + billingMode = groupedWithMinMaxThresholds.billingMode + 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 = - groupedWithProratedMinimum.dimensionalPriceConfiguration + groupedWithMinMaxThresholds.dimensionalPriceConfiguration additionalProperties = - groupedWithProratedMinimum.additionalProperties.toMutableMap() + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -40551,6 +47412,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)) /** @@ -40562,6 +47436,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -40835,20 +47744,21 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = groupedWithMinMaxThresholdsConfig(JsonField.of(groupedWithMinMaxThresholdsConfig)) /** - * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithProratedMinimumConfig] with a well-typed - * [GroupedWithProratedMinimumConfig] value instead. This method is primarily for + * 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 groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: JsonField - ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: JsonField + ) = apply { this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? @@ -40873,6 +47783,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)) /** @@ -40982,7 +47896,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_with_prorated_minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -41102,7 +48016,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithProratedMinimum]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -41111,7 +48025,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -41120,7 +48036,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithProratedMinimumConfig() + * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -41136,12 +48052,16 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithProratedMinimum = - GroupedWithProratedMinimum( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( 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), @@ -41151,8 +48071,8 @@ private constructor( checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), @@ -41173,7 +48093,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithProratedMinimum = apply { + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } @@ -41181,7 +48101,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -41190,7 +48112,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedWithProratedMinimumConfig().validate() + groupedWithMinMaxThresholdsConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -41199,7 +48121,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_prorated_minimum")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -41230,7 +48152,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -41239,7 +48164,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -41248,7 +48173,7 @@ private constructor( (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + @@ -41256,6 +48181,135 @@ private constructor( (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -41400,7 +48454,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() @@ -41408,198 +48462,118 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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 - } + @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()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * The event property used to group before applying thresholds * - * Used for best match union deserialization. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. + * 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). */ - interface Visitor { + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - fun visitUnit(unit: UnitConversionRateConfig): T + /** + * 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 visitTiered(tiered: TieredConversionRateConfig): T + /** + * 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") - /** - * 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") - } - } + /** + * 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 - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { + /** + * 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 ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + /** + * 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 - 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 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 - return ConversionRateConfig(_json = json) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - 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( - @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) @@ -41607,22 +48581,96 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithProratedMinimumConfig]. + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithProratedMinimumConfig]. */ + /** 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() @JvmSynthetic internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + 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 { @@ -41648,21 +48696,41 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.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(): GroupedWithProratedMinimumConfig = apply { + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -41682,24 +48750,38 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -41799,12 +48881,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 @@ -41830,6 +48910,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -41837,6 +48919,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -41851,6 +48934,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -41869,6 +48953,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -41885,6 +48970,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") } @@ -41932,7 +49018,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() @@ -41945,25 +49031,87 @@ 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 GroupedWithMinMaxThresholds && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedWithMinMaxThresholdsConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 GroupedWithMeteredMinimum + class MatrixWithDisplayName + @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, @@ -41972,9 +49120,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, @@ -41998,7 +49146,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -42023,14 +49177,13 @@ 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 @@ -42061,7 +49214,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -42070,9 +49225,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, + matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -42107,12 +49262,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -42165,13 +49333,6 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("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). @@ -42180,11 +49341,23 @@ private constructor( invoicingCycleConfiguration.getOptional("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") + /** + * 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). @@ -42222,9 +49395,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_metered_minimum") + * JsonValue.from("matrix_with_display_name") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -42294,6 +49469,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]. * @@ -42301,6 +49485,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]. * @@ -42377,17 +49571,6 @@ 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]. * @@ -42406,6 +49589,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]. * @@ -42517,15 +49711,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMeteredMinimum]. + * Returns a mutable builder for constructing an instance of [MatrixWithDisplayName]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -42534,9 +49729,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMeteredMinimumConfig() * .invoicingCycleConfiguration() * .item() + * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -42551,13 +49746,15 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimum]. */ + /** 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 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 @@ -42566,17 +49763,15 @@ 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("grouped_with_metered_minimum") + 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 @@ -42586,36 +49781,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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(matrixWithDisplayName: MatrixWithDisplayName) = apply { + id = matrixWithDisplayName.id + billableMetric = matrixWithDisplayName.billableMetric + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + billingMode = matrixWithDisplayName.billingMode + 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)) @@ -42661,6 +49857,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)) /** @@ -42672,6 +49881,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -42945,21 +50189,6 @@ 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)) @@ -42983,6 +50212,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)) /** @@ -42994,6 +50227,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)) @@ -43092,7 +50341,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_with_metered_minimum") + * JsonValue.from("matrix_with_display_name") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -43212,7 +50461,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -43221,7 +50470,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -43230,9 +50481,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMeteredMinimumConfig() * .invoicingCycleConfiguration() * .item() + * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -43246,12 +50497,16 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMeteredMinimum = - GroupedWithMeteredMinimum( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( 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), @@ -43260,12 +50515,9 @@ 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), @@ -43283,7 +50535,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMeteredMinimum = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -43291,7 +50543,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -43300,16 +50554,16 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedWithMeteredMinimumConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() + matrixWithDisplayNameConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_metered_minimum")) { + if (it != JsonValue.from("matrix_with_display_name")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -43340,7 +50594,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -43349,23 +50606,150 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -43510,7 +50894,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() @@ -43518,198 +50902,72 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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 - } + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Used to determine the unit rate * - * Used for best match union deserialization. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + fun dimension(): String = dimension.getRequired("dimension") /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. + * 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). */ - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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) - } - } + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") - return ConversionRateConfig(_json = json) - } - } + /** + * 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 - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + /** + * 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 - 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") - } - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - - class GroupedWithMeteredMinimumConfig - @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) @@ -43717,22 +50975,71 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMeteredMinimumConfig]. + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimumConfig]. */ + /** A builder for [MatrixWithDisplayNameConfig]. */ class Builder internal constructor() { + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = apply { - additionalProperties = - groupedWithMeteredMinimumConfig.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 { @@ -43758,21 +51065,35 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * Returns an immutable instance of [MatrixWithDisplayNameConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GroupedWithMeteredMinimumConfig = apply { + fun validate(): MatrixWithDisplayNameConfig = apply { if (validated) { return@apply } + dimension() + unitAmounts().forEach { it.validate() } validated = true } @@ -43792,24 +51113,294 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitAmount]. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } /** @@ -43909,12 +51500,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 @@ -43940,6 +51529,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -43947,6 +51538,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -43961,6 +51553,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -43979,6 +51572,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -43995,6 +51589,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") } @@ -44042,7 +51637,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() @@ -44055,25 +51650,87 @@ 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 MatrixWithDisplayName && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + matrixWithDisplayNameConfig, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 MatrixWithDisplayName + class GroupedTieredPackage + @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, @@ -44082,9 +51739,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, @@ -44108,7 +51765,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -44133,13 +51796,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 @@ -44170,7 +51833,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -44179,9 +51844,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedTieredPackageConfig, invoicingCycleConfiguration, item, - matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -44216,12 +51881,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -44274,6 +51952,15 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("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). @@ -44282,18 +51969,14 @@ private constructor( invoicingCycleConfiguration.getOptional("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 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). @@ -44331,9 +52014,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("matrix_with_display_name") + * JsonValue.from("grouped_tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -44403,6 +52088,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]. * @@ -44410,6 +52104,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]. * @@ -44486,6 +52190,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]. * @@ -44504,17 +52219,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]. * @@ -44626,14 +52330,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MatrixWithDisplayName]. + * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -44642,9 +52348,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() - * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -44659,13 +52365,15 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixWithDisplayName]. */ + /** 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 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 @@ -44674,15 +52382,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("matrix_with_display_name") + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -44692,34 +52400,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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(groupedTieredPackage: GroupedTieredPackage) = apply { + id = groupedTieredPackage.id + billableMetric = groupedTieredPackage.billableMetric + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + billingMode = groupedTieredPackage.billingMode + 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)) @@ -44765,6 +52476,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)) /** @@ -44776,6 +52500,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -45049,6 +52808,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)) @@ -45072,6 +52846,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)) /** @@ -45083,21 +52861,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)) @@ -45196,7 +52959,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("matrix_with_display_name") + * JsonValue.from("grouped_tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -45316,7 +53079,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithDisplayName]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -45325,7 +53088,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -45334,9 +53099,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() - * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -45350,12 +53115,16 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithDisplayName = - MatrixWithDisplayName( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( 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), @@ -45364,9 +53133,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), @@ -45384,7 +53153,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixWithDisplayName = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -45392,7 +53161,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -45401,16 +53172,16 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + groupedTieredPackageConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() - matrixWithDisplayNameConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("matrix_with_display_name")) { + if (it != JsonValue.from("grouped_tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -45441,7 +53212,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -45450,22 +53224,22 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + - (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -45480,49 +53254,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val CUSTOM = of("custom") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: + * 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -45536,12 +53295,8 @@ private constructor( */ 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 + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -45556,13 +53311,9 @@ private constructor( */ 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") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -45579,7 +53330,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -45609,7 +53360,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -45617,54 +53368,126 @@ 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, - ) { + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ONE_TIME = of("one_time") - fun tiered(): Optional = Optional.ofNullable(tiered) + @JvmField val MONTHLY = of("monthly") - fun isUnit(): Boolean = unit != null + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun isTiered(): Boolean = tiered != null + @JvmField val ANNUAL = of("annual") - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + @JvmField val CUSTOM = of("custom") - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun _json(): Optional = Optional.ofNullable(_json) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + private var validated: Boolean = false - fun validate(): ConversionRateConfig = apply { + fun validate(): Cadence = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + known() validated = true } @@ -45682,133 +53505,108 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - 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 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Cadence && value == other.value } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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() = value.hashCode() - companion object { + override fun toString() = value.toString() + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + @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()) /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. + * 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). */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - 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) { + /** + * 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") - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + /** + * 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") - 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 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 - return ConversionRateConfig(_json = json) - } - } + /** + * 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 - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + /** + * 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 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") - } - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - - class MatrixWithDisplayNameConfig - @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) @@ -45816,22 +53614,91 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MatrixWithDisplayNameConfig]. + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixWithDisplayNameConfig]. */ + /** 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() @JvmSynthetic - internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = - apply { - additionalProperties = - matrixWithDisplayNameConfig.additionalProperties.toMutableMap() - } + 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() @@ -45856,21 +53723,38 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithDisplayNameConfig]. + * Returns an immutable instance of [GroupedTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) + 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(): MatrixWithDisplayNameConfig = apply { + fun validate(): GroupedTieredPackageConfig = apply { if (validated) { return@apply } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -45890,24 +53774,249 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * 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: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + 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 /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -46007,12 +54116,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 @@ -46038,6 +54145,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -46045,6 +54154,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -46059,6 +54169,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -46077,6 +54188,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -46093,6 +54205,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") } @@ -46140,7 +54253,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() @@ -46153,26 +54266,87 @@ 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 GroupedTieredPackage && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedTieredPackageConfig, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 BulkWithProration + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val billableMetric: JsonField, private val billingCycleConfiguration: JsonField, - private val bulkWithProrationConfig: 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, @@ -46183,6 +54357,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, @@ -46206,10 +54381,13 @@ private constructor( @JsonProperty("billing_cycle_configuration") @ExcludeMissing billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bulk_with_proration_config") + @JsonProperty("billing_mode") @ExcludeMissing - bulkWithProrationConfig: JsonField = JsonMissing.of(), + 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(), @@ -46238,6 +54416,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 @@ -46268,8 +54449,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, - bulkWithProrationConfig, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -46280,6 +54462,7 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, + maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -46318,8 +54501,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 bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -46327,6 +54509,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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -46387,11 +54576,23 @@ private constructor( invoicingCycleConfiguration.getOptional("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") + /** + * 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). @@ -46429,9 +54630,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("bulk_with_proration") + * JsonValue.from("max_group_tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -46502,14 +54705,13 @@ private constructor( billingCycleConfiguration /** - * Returns the raw JSON value of [bulkWithProrationConfig]. + * Returns the raw JSON value of [billingMode]. * - * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("bulk_with_proration_config") + @JsonProperty("billing_mode") @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig + fun _billingMode(): JsonField = billingMode /** * Returns the raw JSON value of [cadence]. @@ -46518,6 +54720,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]. * @@ -46612,6 +54824,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]. * @@ -46723,15 +54946,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithProration]. + * Returns a mutable builder for constructing an instance of [MaxGroupTieredPackage]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkWithProrationConfig() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -46742,6 +54966,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -46756,14 +54981,15 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BulkWithProration]. */ + /** 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 bulkWithProrationConfig: 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 @@ -46774,12 +55000,13 @@ 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("bulk_with_proration") + 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 @@ -46789,34 +55016,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + id = maxGroupTieredPackage.id + billableMetric = maxGroupTieredPackage.billableMetric + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + billingMode = maxGroupTieredPackage.billingMode + 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)) @@ -46862,19 +55092,18 @@ private constructor( billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) /** - * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * Sets [Builder.billingMode] 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. + * 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 bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -46887,6 +55116,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -47183,6 +55447,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)) /** @@ -47194,6 +55462,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)) @@ -47292,7 +55576,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("bulk_with_proration") + * JsonValue.from("max_group_tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -47412,7 +55696,7 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithProration]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -47421,8 +55705,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() - * .bulkWithProrationConfig() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -47433,6 +55718,7 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() + * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -47446,13 +55732,16 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithProration = - BulkWithProration( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("billingMode", billingMode), checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, checkRequired("conversionRate", conversionRate), checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), @@ -47463,6 +55752,7 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -47480,7 +55770,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithProration = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -47488,8 +55778,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - bulkWithProrationConfig().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -47500,13 +55791,14 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() + maxGroupTieredPackageConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("bulk_with_proration")) { + if (it != JsonValue.from("max_group_tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -47537,8 +55829,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -47549,89 +55843,116 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - class BulkWithProrationConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + class BillingMode @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 - * [BulkWithProrationConfig]. - */ - @JvmStatic fun builder() = Builder() - } + @JvmField val IN_ADVANCE = of("in_advance") - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } + @JvmField val IN_ARREAR = of("in_arrear") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * 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, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to 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 an immutable instance of [BulkWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } private var validated: Boolean = false - fun validate(): BulkWithProrationConfig = apply { + fun validate(): BillingMode = apply { if (validated) { return@apply } + known() validated = true } @@ -47649,26 +55970,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is BillingMode && value == other.value } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BulkWithProrationConfig{additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -47815,7 +56129,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() @@ -47823,54 +56137,242 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) + @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: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun tiered(): Optional = Optional.ofNullable(tiered) + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { - fun isUnit(): Boolean = unit != null + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isTiered(): Boolean = tiered != null + @JvmSynthetic + internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = + apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + /** + * The event property used to group before tiering the group with the highest value + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** + * 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 _json(): Optional = Optional.ofNullable(_json) + /** Package size */ + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + /** + * 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 } - private var validated: Boolean = false + /** + * Apply tiered pricing to the largest group after grouping with the provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - fun validate(): ConversionRateConfig = apply { - if (validated) { - return@apply + /** + * 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() } } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.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 visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.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: + * ```java + * .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 } @@ -47890,119 +56392,251 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() + /** + * 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 unknown(json: JsonValue?) = 0 - } - ) + /** + * 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 equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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) } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + companion object { - 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") + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() } - companion object { + /** A builder for [Tier]. */ + class Builder internal constructor() { - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { + /** 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: + * ```java + * .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 + } - fun visitUnit(unit: UnitConversionRateConfig): T + tierLowerBound() + unitAmount() + validated = true + } - fun visitTiered(tiered: TieredConversionRateConfig): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Maps an unknown variant of [ConversionRateConfig] to a value of type [T]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + override fun hashCode(): Int = hashCode - 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) - } - } + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - return ConversionRateConfig(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - 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") - } - } + 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}" } /** @@ -48102,12 +56736,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 @@ -48133,6 +56765,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -48140,6 +56774,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -48154,6 +56789,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -48172,6 +56808,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -48188,6 +56825,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") } @@ -48235,7 +56873,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() @@ -48248,25 +56886,87 @@ 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 MaxGroupTieredPackage && + 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 && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maxGroupTieredPackageConfig, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 GroupedTieredPackage + class ScalableMatrixWithUnitPricing + @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, @@ -48275,7 +56975,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, @@ -48288,6 +56987,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, ) { @@ -48301,7 +57002,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -48326,9 +57033,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(), @@ -48355,6 +57059,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 = @@ -48363,7 +57071,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -48372,7 +57082,6 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredPackageConfig, invoicingCycleConfiguration, item, maximum, @@ -48385,6 +57094,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -48409,12 +57119,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -48467,13 +57190,6 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("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). @@ -48482,6 +57198,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -48524,9 +57243,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("grouped_tiered_package") + * JsonValue.from("scalable_matrix_with_unit_pricing") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -48561,6 +57282,17 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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 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). @@ -48596,6 +57328,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]. * @@ -48603,6 +57344,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]. * @@ -48679,17 +57430,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]. * @@ -48793,6 +57533,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]. * @@ -48819,14 +57570,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -48835,7 +57589,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -48847,18 +57600,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithUnitPricingConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedTieredPackage]. */ + /** 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 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 @@ -48867,7 +57623,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 @@ -48875,45 +57630,59 @@ 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_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() @JvmSynthetic - 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(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = + apply { + id = scalableMatrixWithUnitPricing.id + billableMetric = scalableMatrixWithUnitPricing.billableMetric + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + billingMode = scalableMatrixWithUnitPricing.billingMode + 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)) @@ -48958,6 +57727,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)) /** @@ -48969,6 +57751,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -49239,22 +58056,8 @@ private constructor( * supported value. */ fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - 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 } + this.fixedPriceQuantity = fixedPriceQuantity + } fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? @@ -49279,6 +58082,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)) /** @@ -49388,7 +58195,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_tiered_package") + * JsonValue.from("scalable_matrix_with_unit_pricing") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -49465,6 +58272,27 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig + } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -49508,7 +58336,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredPackage]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -49517,7 +58345,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -49526,7 +58356,6 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredPackageConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -49538,16 +58367,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTieredPackage = - GroupedTieredPackage( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( 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), @@ -49556,7 +58390,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -49569,6 +58402,10 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -49576,7 +58413,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTieredPackage = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } @@ -49584,7 +58421,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -49593,7 +58432,6 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedTieredPackageConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -49602,7 +58440,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_tiered_package")) { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -49610,6 +58448,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -49633,7 +58472,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -49642,7 +58484,6 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -49650,13 +58491,145 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -49801,7 +58774,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() @@ -49809,54 +58782,77 @@ 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(): Optional = Optional.ofNullable(unit) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + 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(): Optional = Optional.ofNullable(_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 } @@ -49876,192 +58872,126 @@ private constructor( */ @JvmSynthetic 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - companion object { + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [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. */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = 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") - } - } + companion object { - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { + @JvmField val USAGE_PRICE = of("usage_price") - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + @JvmField val FIXED_PRICE = of("fixed_price") - 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) - } - } + @JvmField val COMPOSITE_PRICE = of("composite_price") - return ConversionRateConfig(_json = json) - } + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } - 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") - } - } + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, } - } - - 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 { + /** + * 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, /** - * Returns a mutable builder for constructing an instance of - * [GroupedTieredPackageConfig]. + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. */ - @JvmStatic fun builder() = Builder() + _UNKNOWN, } - /** A builder for [GroupedTieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to 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 an immutable instance of [GroupedTieredPackageConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } private var validated: Boolean = false - fun validate(): GroupedTieredPackageConfig = apply { + fun validate(): PriceType = apply { if (validated) { return@apply } + known() validated = true } @@ -50079,60 +59009,303 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PriceType && value == other.value } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" + 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 scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = prorate.getOptional("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(): Optional = + secondDimension.getOptional("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) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** 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() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + 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?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * 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)) + + /** + * Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * 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 { @@ -50158,20 +59331,44 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(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(): Metadata = apply { + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { if (validated) { return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + prorate() + secondDimension() validated = true } @@ -50191,152 +59388,323 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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(): Optional = + secondDimensionValue.getOptional("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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the 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 firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } - @JvmField val USAGE_PRICE = of("usage_price") + /** 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 + } - @JvmField val FIXED_PRICE = of("fixed_price") + /** 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 + } - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * 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 + } - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * 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 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) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - 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) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $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().orElseThrow { OrbInvalidDataException("Value is not a String") } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - private var validated: Boolean = false + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 + } - fun validate(): PriceType = apply { - if (validated) { - return@apply + firstDimensionValue() + scalingFactor() + secondDimensionValue() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + 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 } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + 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 /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + prorate, + secondDimension, + additionalProperties, + ) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -50344,25 +59712,87 @@ 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 ScalableMatrixWithUnitPricing && + 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 && + scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + scalableMatrixWithUnitPricingConfig, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 MaxGroupTieredPackage + class ScalableMatrixWithTieredPricing + @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, @@ -50373,7 +59803,6 @@ 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, @@ -50384,6 +59813,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, ) { @@ -50397,7 +59828,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -50426,9 +59863,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 @@ -50451,6 +59885,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 = @@ -50459,7 +59898,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -50470,7 +59911,6 @@ private constructor( fixedPriceQuantity, invoicingCycleConfiguration, item, - maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -50481,6 +59921,7 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -50505,12 +59946,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -50571,18 +60025,14 @@ private constructor( invoicingCycleConfiguration.getOptional("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 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). @@ -50620,9 +60070,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("max_group_tiered_package") + * JsonValue.from("scalable_matrix_with_tiered_pricing") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -50657,6 +60109,17 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -50692,6 +60155,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]. * @@ -50699,6 +60171,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]. * @@ -50793,17 +60275,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]. * @@ -50889,6 +60360,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]. * @@ -50915,14 +60397,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MaxGroupTieredPackage]. + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -50933,7 +60418,6 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -50943,18 +60427,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithTieredPricingConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackage]. */ + /** 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 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 @@ -50965,51 +60452,64 @@ 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("max_group_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() @JvmSynthetic - 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(scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing) = + apply { + id = scalableMatrixWithTieredPricing.id + billableMetric = scalableMatrixWithTieredPricing.billableMetric + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + billingMode = scalableMatrixWithTieredPricing.billingMode + 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)) @@ -51054,6 +60554,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)) /** @@ -51065,6 +60578,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -51361,6 +60909,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)) /** @@ -51372,21 +60924,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)) @@ -51485,7 +61022,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("max_group_tiered_package") + * JsonValue.from("scalable_matrix_with_tiered_pricing") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -51562,6 +61099,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)) @@ -51605,7 +61164,7 @@ private constructor( } /** - * Returns an immutable instance of [MaxGroupTieredPackage]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -51614,7 +61173,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -51625,7 +61186,6 @@ private constructor( * .fixedPriceQuantity() * .invoicingCycleConfiguration() * .item() - * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -51635,16 +61195,21 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): MaxGroupTieredPackage = - MaxGroupTieredPackage( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( 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), @@ -51655,7 +61220,6 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -51666,6 +61230,10 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -51673,7 +61241,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MaxGroupTieredPackage = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } @@ -51681,7 +61249,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -51692,14 +61262,13 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() - maxGroupTieredPackageConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("max_group_tiered_package")) { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -51707,6 +61276,7 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -51730,7 +61300,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -51741,19 +61314,150 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + - (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -51898,7 +61602,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() @@ -51906,54 +61610,77 @@ 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(): Optional = Optional.ofNullable(unit) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun tiered(): Optional = Optional.ofNullable(tiered) + private var additionalProperties: MutableMap = mutableMapOf() - fun isUnit(): Boolean = unit != null + @JvmSynthetic + 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(): Optional = Optional.ofNullable(_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 } @@ -51973,193 +61700,126 @@ private constructor( */ @JvmSynthetic 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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") - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - companion object { + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [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. */ - interface Visitor { - - fun visitUnit(unit: UnitConversionRateConfig): T - - fun visitTiered(tiered: TieredConversionRateConfig): T + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = 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") - } - } + companion object { - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { + @JvmField val USAGE_PRICE = of("usage_price") - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + @JvmField val FIXED_PRICE = of("fixed_price") - 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) - } - } + @JvmField val COMPOSITE_PRICE = of("composite_price") - return ConversionRateConfig(_json = json) - } + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } - 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") - } - } + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, } - } - - class MaxGroupTieredPackageConfig - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { + /** + * 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, /** - * Returns a mutable builder for constructing an instance of - * [MaxGroupTieredPackageConfig]. + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. */ - @JvmStatic fun builder() = Builder() + _UNKNOWN, } - /** A builder for [MaxGroupTieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to 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 an immutable instance of [MaxGroupTieredPackageConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } private var validated: Boolean = false - fun validate(): MaxGroupTieredPackageConfig = apply { + fun validate(): PriceType = apply { if (validated) { return@apply } + known() validated = true } @@ -52177,60 +61837,264 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PriceType && value == other.value } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" + 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 scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) 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(): Optional = + secondDimension.getOptional("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: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ @JvmStatic 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() @JvmSynthetic - 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)) + + /** + * Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * 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 { @@ -52256,20 +62120,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: + * ```java + * .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 } @@ -52289,152 +62175,541 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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(): Optional = + secondDimensionValue.getOptional("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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the 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 firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } - @JvmField val USAGE_PRICE = of("usage_price") + /** 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 + } - @JvmField val FIXED_PRICE = of("fixed_price") + /** 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 + } - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } + /** Second dimension value (optional) */ + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * 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 + } - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.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: + * ```java + * .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 + } - /** - * 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, + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + 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 + @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()) + + /** + * 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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().orElseThrow { 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 + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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. - */ - @JvmSynthetic 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 /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + 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 { @@ -52442,29 +62717,93 @@ 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 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 } - /* 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 */ + 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() = - "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}" + "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 ScalableMatrixWithUnitPricing + 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, @@ -52481,8 +62820,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, ) { @@ -52496,7 +62833,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -52509,6 +62852,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(), @@ -52547,10 +62893,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 = @@ -52559,11 +62901,14 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedBulkConfig, currency, discount, externalPriceId, @@ -52580,7 +62925,6 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -52605,12 +62949,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -52637,6 +62994,15 @@ private constructor( fun creditAllocation(): Optional = creditAllocation.getOptional("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). @@ -52671,6 +63037,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -52713,9 +63082,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("scalable_matrix_with_unit_pricing") + * JsonValue.from("cumulative_grouped_bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -52750,15 +63121,6 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -52794,6 +63156,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]. * @@ -52801,6 +63172,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]. * @@ -52840,6 +63221,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]. * @@ -52980,17 +63372,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]. * @@ -53017,19 +63398,21 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithUnitPricing]. + * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() * .creditAllocation() + * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() @@ -53045,23 +63428,25 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithUnitPricingConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ScalableMatrixWithUnitPricing]. */ + /** 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 @@ -53073,54 +63458,48 @@ 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("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 scalableMatrixWithUnitPricingConfig: - JsonField? = - null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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(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)) @@ -53165,6 +63544,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)) /** @@ -53176,6 +63568,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -53303,6 +63730,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)) /** @@ -53472,6 +63915,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)) /** @@ -53581,7 +64028,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("scalable_matrix_with_unit_pricing") + * JsonValue.from("cumulative_grouped_bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -53658,26 +64105,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)) @@ -53721,7 +64148,7 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -53730,11 +64157,14 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() * .creditAllocation() + * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() @@ -53750,21 +64180,25 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithUnitPricing = - ScalableMatrixWithUnitPricing( + 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), @@ -53781,10 +64215,6 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired( - "scalableMatrixWithUnitPricingConfig", - scalableMatrixWithUnitPricingConfig, - ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -53792,7 +64222,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ScalableMatrixWithUnitPricing = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -53800,11 +64230,14 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() creditAllocation().ifPresent { it.validate() } + cumulativeGroupedBulkConfig().validate() currency() discount().ifPresent { it.validate() } externalPriceId() @@ -53817,7 +64250,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + if (it != JsonValue.from("cumulative_grouped_bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -53825,7 +64258,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -53849,11 +64281,15 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + @@ -53865,16 +64301,142 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -54019,7 +64581,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() @@ -54027,54 +64589,194 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) + @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: + * ```java + * .dimensionValues() + * .group() + * ``` + */ + @JvmStatic 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() - fun tiered(): Optional = Optional.ofNullable(tiered) + @JvmSynthetic + internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = + apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { it.toMutableList() } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } - fun isUnit(): Boolean = unit != null + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) - fun isTiered(): Boolean = tiered != null + /** + * 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() } + } - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + /** Grouping key name */ + fun group(group: String) = group(JsonField.of(group)) - fun _json(): Optional = Optional.ofNullable(_json) + /** + * 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 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 [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(): ConversionRateConfig = apply { + fun validate(): CumulativeGroupedBulkConfig = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) { - unit.validate() - } - - override fun visitTiered(tiered: TieredConversionRateConfig) { - tiered.validate() - } - } - ) + dimensionValues().forEach { it.validate() } + group() validated = true } @@ -54094,119 +64796,294 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown().isPresent) 1 else 0) + + /** 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()) - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.validity() + /** + * 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") - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * 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 equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * 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) } - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + companion object { - 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") + /** + * Returns a mutable builder for constructing an instance of [DimensionValue]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() } - companion object { + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + @JvmSynthetic + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = dimensionValue.additionalProperties.toMutableMap() + } - /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. - */ - interface Visitor { + /** 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 + } - fun visitUnit(unit: UnitConversionRateConfig): T + /** 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 visitTiered(tiered: TieredConversionRateConfig): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.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: + * ```java + * .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 + } /** - * 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. + * 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 ConversionRateConfig: $json") + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 } - } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tierLowerBound, unitAmount, additionalProperties) + } - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + override fun hashCode(): Int = hashCode - 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) - } - } + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - return ConversionRateConfig(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } - 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") - } - } + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" } /** @@ -54306,12 +65183,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 @@ -54337,6 +65212,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -54344,6 +65221,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -54358,6 +65236,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -54376,6 +65255,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -54392,6 +65272,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") } @@ -54439,7 +65320,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() @@ -54447,142 +65328,92 @@ 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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { 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 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 } - /* 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 */ + 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() = - "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}" + "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 ScalableMatrixWithTieredPricing + 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, @@ -54598,13 +65429,12 @@ 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, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val scalableMatrixWithTieredPricingConfig: - JsonField, private val dimensionalPriceConfiguration: JsonField, private val additionalProperties: MutableMap, ) { @@ -54618,7 +65448,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -54658,6 +65494,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") @@ -54669,11 +65508,6 @@ 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 = @@ -54682,7 +65516,9 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, @@ -54698,12 +65534,12 @@ private constructor( metadata, minimum, minimumAmount, + minimumConfig, modelType, name, planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, mutableMapOf(), ) @@ -54728,12 +65564,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -54794,6 +65643,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -54836,9 +65688,19 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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: * ```java - * JsonValue.from("scalable_matrix_with_tiered_pricing") + * JsonValue.from("minimum") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -54873,15 +65735,6 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("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). @@ -54917,6 +65770,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]. * @@ -54924,6 +65786,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]. * @@ -55067,6 +65939,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]. * @@ -55103,17 +65985,6 @@ 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]. * @@ -55140,15 +66011,16 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithTieredPricing]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -55164,23 +66036,25 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() + * .minimumConfig() * .name() * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithTieredPricingConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ScalableMatrixWithTieredPricing]. */ + /** 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 @@ -55196,54 +66070,48 @@ 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 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 scalableMatrixWithTieredPricingConfig: - JsonField? = - null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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() - } + 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)) @@ -55288,6 +66156,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)) /** @@ -55299,6 +66180,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -55595,6 +66511,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)) /** @@ -55698,13 +66618,28 @@ 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: * ```java - * JsonValue.from("scalable_matrix_with_tiered_pricing") + * JsonValue.from("minimum") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -55781,27 +66716,6 @@ 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)) @@ -55845,7 +66759,7 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -55854,7 +66768,9 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() @@ -55870,21 +66786,25 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() + * .minimumConfig() * .name() * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithTieredPricing = - ScalableMatrixWithTieredPricing( + 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), @@ -55900,15 +66820,12 @@ private constructor( 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), - checkRequired( - "scalableMatrixWithTieredPricingConfig", - scalableMatrixWithTieredPricingConfig, - ), dimensionalPriceConfiguration, additionalProperties.toMutableMap(), ) @@ -55916,7 +66833,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ScalableMatrixWithTieredPricing = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } @@ -55924,7 +66841,9 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() @@ -55940,8 +66859,9 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() + minimumConfig().validate() _modelType().let { - if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + if (it != JsonValue.from("minimum")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -55949,7 +66869,6 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -55973,7 +66892,10 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + @@ -55989,16 +66911,143 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 - } + + (minimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -56143,7 +67192,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() @@ -56151,54 +67200,77 @@ 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(): Optional = Optional.ofNullable(unit) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) - fun tiered(): Optional = Optional.ofNullable(tiered) + companion object { - fun isUnit(): Boolean = unit != null + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun isTiered(): Boolean = tiered != null + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun asUnit(): UnitConversionRateConfig = unit.getOrThrow("unit") + private var additionalProperties: MutableMap = mutableMapOf() - fun asTiered(): TieredConversionRateConfig = tiered.getOrThrow("tiered") + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun _json(): Optional = Optional.ofNullable(_json) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - else -> visitor.unknown(_json) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.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(): 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 } @@ -56218,155 +67290,143 @@ private constructor( */ @JvmSynthetic 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + return other is Metadata && additionalProperties == other.additionalProperties } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + 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 - companion object { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) + /** 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, + ) { - @JvmStatic - fun ofTiered(tiered: TieredConversionRateConfig) = - ConversionRateConfig(tiered = tiered) - } + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) /** - * An interface that defines how to map each variant of [ConversionRateConfig] to a - * value of type [T]. + * 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). */ - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - 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) - } - } + /** + * 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(): Optional = prorated.getOptional("prorated") - return ConversionRateConfig(_json = json) - } - } + /** + * 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 - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + /** + * 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 - 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") - } - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - - /** - * 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 _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: + * ```java + * .minimumAmount() + * ``` + */ @JvmStatic 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() @JvmSynthetic - 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 + } + + /** 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) @@ -56390,20 +67450,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: + * ```java + * .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 } @@ -56423,23 +67497,28 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (prorated.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is MinimumConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + 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) : @@ -56461,6 +67540,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -56468,6 +67549,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -56482,6 +67564,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -56500,6 +67583,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -56516,6 +67600,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") } @@ -56563,7 +67648,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() @@ -56571,147 +67656,96 @@ 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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { 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 Minimum && + 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 && + minimumConfig == other.minimumConfig && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + minimumConfig, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + 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}" + "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 CumulativeGroupedBulk + class Percent + @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, @@ -56725,6 +67759,7 @@ private constructor( private val minimumAmount: 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, @@ -56741,7 +67776,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -56754,9 +67795,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(), @@ -56786,6 +67824,9 @@ private constructor( minimumAmount: 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(), @@ -56803,12 +67844,13 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, currency, discount, externalPriceId, @@ -56822,6 +67864,7 @@ private constructor( minimumAmount, modelType, name, + percentConfig, planPhaseOrder, priceType, replacesPriceId, @@ -56849,12 +67892,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -56881,13 +67937,6 @@ private constructor( fun creditAllocation(): Optional = creditAllocation.getOptional("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). @@ -56922,6 +67971,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -56964,9 +68016,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_bulk") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -56980,6 +68034,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). @@ -57036,6 +68098,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]. * @@ -57043,6 +68114,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]. * @@ -57082,17 +68163,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]. * @@ -57204,6 +68274,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 [planPhaseOrder]. * @@ -57259,19 +68339,20 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() @@ -57284,6 +68365,7 @@ private constructor( * .minimum() * .minimumAmount() * .name() + * .percentConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() @@ -57292,18 +68374,19 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulk]. */ + /** A builder for [Percent]. */ 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 @@ -57315,8 +68398,9 @@ 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("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 @@ -57325,34 +68409,36 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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() + 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)) @@ -57398,6 +68484,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)) /** @@ -57409,6 +68508,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -57536,21 +68670,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)) /** @@ -57720,6 +68839,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)) /** @@ -57829,7 +68952,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("cumulative_grouped_bulk") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -57848,6 +68971,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)) @@ -57949,7 +69087,7 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedBulk]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -57958,12 +69096,13 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() @@ -57976,6 +69115,7 @@ private constructor( * .minimum() * .minimumAmount() * .name() + * .percentConfig() * .planPhaseOrder() * .priceType() * .replacesPriceId() @@ -57983,17 +69123,20 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedBulk = - CumulativeGroupedBulk( + fun build(): Percent = + Percent( 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), @@ -58007,6 +69150,7 @@ private constructor( checkRequired("minimumAmount", minimumAmount), modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), @@ -58017,7 +69161,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedBulk = apply { + fun validate(): Percent = apply { if (validated) { return@apply } @@ -58025,12 +69169,13 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() creditAllocation().ifPresent { it.validate() } - cumulativeGroupedBulkConfig().validate() currency() discount().ifPresent { it.validate() } externalPriceId() @@ -58043,11 +69188,12 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_bulk")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() planPhaseOrder() priceType().validate() replacesPriceId() @@ -58074,12 +69220,14 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + @@ -58091,13 +69239,143 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -58242,7 +69520,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() @@ -58250,189 +69528,12 @@ 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(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - 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 /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ - - 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 { - - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() - - 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 + /** + * 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 @@ -58447,24 +69548,19 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedBulkConfig]. - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulkConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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() @@ -58489,17 +69585,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 } @@ -58530,53 +69625,96 @@ private constructor( return true } - return /* spotless:off */ other is CumulativeGroupedBulkConfig && 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 - 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 + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + 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 = 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 [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + 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) @@ -58600,20 +69738,32 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } + percent() validated = true } @@ -58631,25 +69781,24 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + @JvmSynthetic internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } class PriceType @JsonCreator private constructor(private val value: JsonField) : @@ -58671,6 +69820,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -58678,6 +69829,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -58692,6 +69844,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -58710,6 +69863,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -58726,6 +69880,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") } @@ -58773,7 +69928,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() @@ -58786,34 +69941,96 @@ 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 Percent && + 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 && + percentConfig == other.percentConfig && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + additionalProperties == other.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 */ + 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, + percentConfig, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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 GroupedWithMinMaxThresholds + class EventOutput + @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 eventOutputConfig: 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, @@ -58839,7 +70056,13 @@ 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 + compositePriceFilters: JsonField> = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing conversionRate: JsonField = JsonMissing.of(), @@ -58858,16 +70081,15 @@ 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(), @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(), @@ -58902,16 +70124,18 @@ private constructor( id, billableMetric, billingCycleConfiguration, + billingMode, cadence, + compositePriceFilters, conversionRate, conversionRateConfig, createdAt, creditAllocation, currency, discount, + eventOutputConfig, externalPriceId, fixedPriceQuantity, - groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration, item, maximum, @@ -58948,12 +70172,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 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(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -58993,6 +70230,15 @@ private constructor( @Deprecated("deprecated") fun discount(): Optional = discount.getOptional("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). @@ -59006,13 +70252,6 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("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). @@ -59021,6 +70260,9 @@ private constructor( invoicingCycleConfiguration.getOptional("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). */ @@ -59063,9 +70305,11 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") /** + * The pricing model type + * * Expected to always return the following: * ```java - * 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 @@ -59135,6 +70379,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]. * @@ -59142,6 +70395,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]. * @@ -59198,6 +70461,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]. * @@ -59218,17 +70491,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]. * @@ -59358,24 +70620,25 @@ 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: * ```java * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() * .creditAllocation() * .currency() * .discount() + * .eventOutputConfig() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -59392,24 +70655,24 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [EventOutput]. */ 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 eventOutputConfig: 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 @@ -59417,7 +70680,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("event_output") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -59427,38 +70690,36 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - 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(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)) @@ -59504,6 +70765,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)) /** @@ -59515,6 +70789,41 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * 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)) @@ -59741,6 +71050,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)) @@ -59788,21 +71112,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)) @@ -59826,6 +71135,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)) /** @@ -59935,7 +71248,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * 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 @@ -60055,7 +71368,7 @@ 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. * @@ -60064,16 +71377,18 @@ private constructor( * .id() * .billableMetric() * .billingCycleConfiguration() + * .billingMode() * .cadence() + * .compositePriceFilters() * .conversionRate() * .conversionRateConfig() * .createdAt() * .creditAllocation() * .currency() * .discount() + * .eventOutputConfig() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMinMaxThresholdsConfig() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -60089,24 +71404,25 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): EventOutput = + EventOutput( 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("eventOutputConfig", eventOutputConfig), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -60126,7 +71442,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): EventOutput = apply { if (validated) { return@apply } @@ -60134,16 +71450,18 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + billingMode().validate() cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } conversionRate() conversionRateConfig().ifPresent { it.validate() } createdAt() creditAllocation().ifPresent { it.validate() } currency() discount().ifPresent { it.validate() } + eventOutputConfig().validate() externalPriceId() fixedPriceQuantity() - groupedWithMinMaxThresholdsConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -60152,7 +71470,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("event_output")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -60183,16 +71501,19 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (conversionRate.asKnown().isPresent) 1 else 0) + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -60200,15 +71521,142 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - 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().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.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 { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic 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().orElseThrow { 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. + */ + @JvmSynthetic internal 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 { @@ -60353,7 +71801,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() @@ -60361,221 +71809,137 @@ private constructor( override fun toString() = value.toString() } - @JsonDeserialize(using = ConversionRateConfig.Deserializer::class) - @JsonSerialize(using = ConversionRateConfig.Serializer::class) - class ConversionRateConfig + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: UnitConversionRateConfig? = null, - private val tiered: TieredConversionRateConfig? = null, - private val _json: JsonValue? = null, + private val unitRatingKey: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) - - fun tiered(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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 - } + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, groupingKey, mutableMapOf()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * The key in the event data to extract the unit rate from. * - * Used for best match union deserialization. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: UnitConversionRateConfig) = unit.validity() + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - override fun visitTiered(tiered: TieredConversionRateConfig) = - tiered.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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * 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 equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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 - return /* spotless:off */ other is ConversionRateConfig && unit == other.unit && tiered == other.tiered /* spotless:on */ + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, tiered) /* spotless:on */ + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(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") - } + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun ofUnit(unit: UnitConversionRateConfig) = ConversionRateConfig(unit = unit) - - @JvmStatic - 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. + * Returns a mutable builder for constructing an instance of [EventOutputConfig]. * - * @throws OrbInvalidDataException in the default implementation. + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown ConversionRateConfig: $json") - } + @JvmStatic fun builder() = Builder() } - internal class Deserializer : - BaseDeserializer(ConversionRateConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ConversionRateConfig { - val json = JsonValue.fromJsonNode(node) - val conversionRateType = - json - .asObject() - .getOrNull() - ?.get("conversion_rate_type") - ?.asString() - ?.getOrNull() + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - 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) - } - } + private var unitRatingKey: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - return ConversionRateConfig(_json = json) + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = eventOutputConfig.additionalProperties.toMutableMap() } - } - internal class Serializer : - BaseSerializer(ConversionRateConfig::class) { + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - 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") - } + /** + * 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 } - } - } - - 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]. + * An optional key in the event data to group by (e.g., event ID). All events will + * also be grouped by their unit rate. */ - @JvmStatic fun builder() = Builder() - } + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) - @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() + /** + * 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 { @@ -60601,21 +71965,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: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig(additionalProperties.toImmutable()) + 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() validated = true } @@ -60635,24 +72012,28 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedWithMinMaxThresholdsConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash(unitRatingKey, groupingKey, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{additionalProperties=$additionalProperties}" + "EventOutputConfig{unitRatingKey=$unitRatingKey, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" } /** @@ -60752,12 +72133,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 @@ -60783,6 +72162,8 @@ private constructor( @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } @@ -60790,6 +72171,7 @@ private constructor( enum class Known { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, } /** @@ -60804,6 +72186,7 @@ private constructor( enum class Value { USAGE_PRICE, FIXED_PRICE, + COMPOSITE_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown * value. @@ -60822,6 +72205,7 @@ private constructor( when (this) { USAGE_PRICE -> Value.USAGE_PRICE FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -60838,6 +72222,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") } @@ -60885,7 +72270,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() @@ -60898,16 +72283,75 @@ 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 EventOutput && + 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 && + eventOutputConfig == other.eventOutputConfig && + 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: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 */ + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + eventOutputConfig, + externalPriceId, + fixedPriceQuantity, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + additionalProperties, + ) + } 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}" + "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-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index e783f8dc..6aca0d0c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -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 import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -41,6 +51,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. */ @@ -78,36 +89,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.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)) + /** 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)) @@ -116,21 +115,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 @@ -139,10 +130,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)) @@ -155,6 +154,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)`. @@ -169,18 +172,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)`. @@ -199,6 +209,15 @@ private constructor( fun body(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = body(Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** 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)) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -323,62 +342,55 @@ 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 tieredBps: NewFloatingTieredBpsPrice? = null, - private val bps: NewFloatingBpsPrice? = null, - private val bulkBps: NewFloatingBulkBpsPrice? = 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 minimum: NewFloatingMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) @@ -386,24 +398,24 @@ private constructor( fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) - - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) - fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) fun tieredPackageWithMinimum(): Optional = Optional.ofNullable(tieredPackageWithMinimum) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -413,21 +425,27 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) - fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + fun scalableMatrixWithUnitPricing(): Optional = Optional.ofNullable(scalableMatrixWithUnitPricing) @@ -439,80 +457,79 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun isUnit(): Boolean = unit != null + fun minimum(): Optional = Optional.ofNullable(minimum) - fun isPackage(): Boolean = package_ != null + fun percent(): Optional = Optional.ofNullable(percent) - fun isMatrix(): Boolean = matrix != null + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != null + fun isMatrix(): Boolean = matrix != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null - fun isGroupedTiered(): Boolean = groupedTiered != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != 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 asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") + fun isMinimum(): Boolean = minimum != null - fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") + fun isPercent(): Boolean = percent != null - fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") + fun isEventOutput(): Boolean = eventOutput != null - fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewFloatingTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewFloatingBpsPrice = bps.getOrThrow("bps") + fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") - fun asBulkBps(): NewFloatingBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") - fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -520,24 +537,24 @@ private constructor( 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") @@ -547,21 +564,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") @@ -571,50 +594,58 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): Optional = Optional.ofNullable(_json) 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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -631,38 +662,20 @@ 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() } - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewFloatingBpsPrice) { - bps.validate() + override fun visitBulk(bulk: NewFloatingBulkPrice) { + bulk.validate() } - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) { - bulkBps.validate() + override fun visitPackage(package_: NewFloatingPackagePrice) { + package_.validate() } - override fun visitBulk(bulk: NewFloatingBulkPrice) { - bulk.validate() + override fun visitMatrix(matrix: NewFloatingMatrixPrice) { + matrix.validate() } override fun visitThresholdTotalAmount( @@ -675,26 +688,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( @@ -703,12 +704,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 ) { @@ -727,10 +740,16 @@ private constructor( groupedAllocation.validate() } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice ) { - groupedWithProratedMinimum.validate() + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( @@ -739,16 +758,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( @@ -757,6 +776,12 @@ private constructor( groupedTieredPackage.validate() } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice ) { @@ -775,6 +800,18 @@ private constructor( ) { cumulativeGroupedBulk.validate() } + + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -800,25 +837,14 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewFloatingUnitPrice) = unit.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 visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewFloatingBpsPrice) = bps.validity() + override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) = bulkBps.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = + package_.validity() - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitMatrix(matrix: NewFloatingMatrixPrice) = matrix.validity() override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice @@ -827,29 +853,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() @@ -862,6 +888,10 @@ private constructor( groupedAllocation: NewFloatingGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -870,18 +900,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() @@ -895,6 +929,13 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + 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 } ) @@ -904,50 +945,112 @@ 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 && + 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 = /* 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, + 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 -> "Body{unit=$unit}" - package_ != null -> "Body{package_=$package_}" - 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}" + 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}" + 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") } @@ -956,24 +1059,13 @@ private constructor( @JvmStatic fun ofUnit(unit: NewFloatingUnitPrice) = Body(unit = unit) - @JvmStatic fun ofPackage(package_: NewFloatingPackagePrice) = Body(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: NewFloatingMatrixPrice) = Body(matrix = matrix) - - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = - Body(matrixWithAllocation = matrixWithAllocation) - @JvmStatic fun ofTiered(tiered: NewFloatingTieredPrice) = Body(tiered = tiered) - @JvmStatic - fun ofTieredBps(tieredBps: NewFloatingTieredBpsPrice) = Body(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: NewFloatingBpsPrice) = Body(bps = bps) + @JvmStatic fun ofBulk(bulk: NewFloatingBulkPrice) = Body(bulk = bulk) - @JvmStatic fun ofBulkBps(bulkBps: NewFloatingBulkBpsPrice) = Body(bulkBps = bulkBps) + @JvmStatic fun ofPackage(package_: NewFloatingPackagePrice) = Body(package_ = package_) - @JvmStatic fun ofBulk(bulk: NewFloatingBulkPrice) = Body(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: NewFloatingMatrixPrice) = Body(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount(thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice) = @@ -983,33 +1075,32 @@ private constructor( fun ofTieredPackage(tieredPackage: NewFloatingTieredPackagePrice) = Body(tieredPackage = tieredPackage) - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = - Body(groupedTiered = groupedTiered) - - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Body(maxGroupTieredPackage = maxGroupTieredPackage) - @JvmStatic fun ofTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = Body(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Body(packageWithAllocation = packageWithAllocation) + fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = + Body(groupedTiered = groupedTiered) @JvmStatic fun ofTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = Body(tieredPackageWithMinimum = tieredPackageWithMinimum) + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = Body(packageWithAllocation = packageWithAllocation) + @JvmStatic fun ofUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice) = Body(unitWithPercent = unitWithPercent) + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = + Body(matrixWithAllocation = matrixWithAllocation) + @JvmStatic fun ofTieredWithProration(tieredWithProration: NewFloatingTieredWithProrationPrice) = Body(tieredWithProration = tieredWithProration) @@ -1022,6 +1113,10 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice) = Body(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = + Body(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice @@ -1032,19 +1127,25 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = Body(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Body(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JvmStatic fun ofMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = Body(matrixWithDisplayName = matrixWithDisplayName) - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = - Body(bulkWithProration = bulkWithProration) - @JvmStatic fun ofGroupedTieredPackage(groupedTieredPackage: NewFloatingGroupedTieredPackagePrice) = Body(groupedTieredPackage = groupedTieredPackage) + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = Body(maxGroupTieredPackage = maxGroupTieredPackage) + @JvmStatic fun ofScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -1059,6 +1160,13 @@ private constructor( fun ofCumulativeGroupedBulk( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Body(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Body(minimum = minimum) + + @JvmStatic fun ofPercent(percent: Percent) = Body(percent = percent) + + @JvmStatic fun ofEventOutput(eventOutput: EventOutput) = Body(eventOutput = eventOutput) } /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ @@ -1066,23 +1174,13 @@ 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 visitTieredBps(tieredBps: NewFloatingTieredBpsPrice): T - - fun visitBps(bps: NewFloatingBpsPrice): T + fun visitBulk(bulk: NewFloatingBulkPrice): T - fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice): T + fun visitPackage(package_: NewFloatingPackagePrice): T - fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitMatrix(matrix: NewFloatingMatrixPrice): T fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice @@ -1090,24 +1188,24 @@ private constructor( 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 @@ -1116,6 +1214,8 @@ private constructor( fun visitGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ): T @@ -1124,16 +1224,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 @@ -1146,6 +1252,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Body] to a value of type [T]. * @@ -1173,46 +1285,25 @@ 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) } ?: 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) } ?: 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, @@ -1225,18 +1316,6 @@ 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" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(maxGroupTieredPackage = it, _json = json) } - ?: Body(_json = json) - } "tiered_with_minimum" -> { return tryDeserialize( node, @@ -1245,20 +1324,24 @@ private constructor( ?.let { Body(tieredWithMinimum = it, _json = json) } ?: Body(_json = json) } - "package_with_allocation" -> { + "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(packageWithAllocation = it, _json = json) } + ?.let { Body(tieredPackageWithMinimum = it, _json = json) } ?: Body(_json = json) } - "tiered_package_with_minimum" -> { + "package_with_allocation" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Body(tieredPackageWithMinimum = it, _json = json) } + ?.let { Body(packageWithAllocation = it, _json = json) } ?: Body(_json = json) } "unit_with_percent" -> { @@ -1268,7 +1351,15 @@ private constructor( ) ?.let { Body(unitWithPercent = it, _json = json) } ?: Body(_json = json) } - "tiered_with_proration" -> { + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Body(matrixWithAllocation = it, _json = json) } + ?: Body(_json = json) + } + "tiered_with_proration" -> { return tryDeserialize( node, jacksonTypeRef(), @@ -1292,6 +1383,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, @@ -1308,6 +1407,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, @@ -1316,20 +1420,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" -> { @@ -1356,6 +1460,23 @@ private constructor( ?.let { Body(cumulativeGroupedBulk = it, _json = json) } ?: Body(_json = json) } + "minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.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) + } ?: Body(_json = json) + } } return Body(_json = json) @@ -1371,55 +1492,4834 @@ 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.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.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.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") } } } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. 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)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. 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)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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( + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. 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)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 { @@ -1427,10 +6327,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-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index e6ea9024..2de2e780 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-java-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 @@ -432,6 +433,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, @@ -783,12 +785,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 @@ -797,6 +812,7 @@ private constructor( } class PriceEvaluation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalPriceId: JsonField, private val filter: JsonField, @@ -847,8 +863,7 @@ private constructor( fun groupingKeys(): Optional> = groupingKeys.getOptional("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). @@ -1009,10 +1024,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)) /** Alias for calling [Builder.price] with `price.orElse(null)`. */ @@ -1030,33 +1042,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.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)) + /** 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)`. */ @@ -1067,20 +1064,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 @@ -1089,17 +1086,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)`. */ @@ -1114,6 +1110,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)`. @@ -1128,6 +1128,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)`. @@ -1135,16 +1142,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)`. @@ -1168,6 +1178,15 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** 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)) + /** The ID of a price to evaluate that exists in your Orb account. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1255,41 +1274,36 @@ private constructor( (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) - /** - * 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 tieredBps: NewFloatingTieredBpsPrice? = null, - private val bps: NewFloatingBpsPrice? = null, - private val bulkBps: NewFloatingBulkBpsPrice? = 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, @@ -1297,27 +1311,21 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = 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, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) @@ -1325,24 +1333,24 @@ private constructor( fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) - - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) - fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) fun tieredPackageWithMinimum(): Optional = Optional.ofNullable(tieredPackageWithMinimum) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -1352,21 +1360,27 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) - fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + fun scalableMatrixWithUnitPricing(): Optional = Optional.ofNullable(scalableMatrixWithUnitPricing) @@ -1378,56 +1392,58 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun isUnit(): Boolean = unit != null + fun minimum(): Optional = Optional.ofNullable(minimum) - fun isPackage(): Boolean = package_ != null + fun percent(): Optional = Optional.ofNullable(percent) - fun isMatrix(): Boolean = matrix != null + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != null + fun isMatrix(): Boolean = matrix != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null - fun isGroupedTiered(): Boolean = groupedTiered != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != 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 = @@ -1435,24 +1451,21 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") + fun isMinimum(): Boolean = minimum != null - fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") + fun isPercent(): Boolean = percent != null - fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") + fun isEventOutput(): Boolean = eventOutput != null - fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewFloatingTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewFloatingBpsPrice = bps.getOrThrow("bps") + fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") - fun asBulkBps(): NewFloatingBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") - fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -1460,24 +1473,24 @@ private constructor( 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") @@ -1487,21 +1500,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") @@ -1512,45 +1531,50 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): Optional = Optional.ofNullable(_json) 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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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 -> @@ -1559,6 +1583,9 @@ 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) } @@ -1575,38 +1602,20 @@ 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() } - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewFloatingBpsPrice) { - bps.validate() + override fun visitBulk(bulk: NewFloatingBulkPrice) { + bulk.validate() } - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) { - bulkBps.validate() + override fun visitPackage(package_: NewFloatingPackagePrice) { + package_.validate() } - override fun visitBulk(bulk: NewFloatingBulkPrice) { - bulk.validate() + override fun visitMatrix(matrix: NewFloatingMatrixPrice) { + matrix.validate() } override fun visitThresholdTotalAmount( @@ -1621,42 +1630,42 @@ 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() + tieredPackageWithMinimum.validate() } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewFloatingTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } - - override fun visitPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice + override fun visitPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice ) { 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 ) { @@ -1675,6 +1684,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) { @@ -1687,16 +1702,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( @@ -1705,6 +1720,12 @@ private constructor( groupedTieredPackage.validate() } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -1724,6 +1745,18 @@ private constructor( ) { cumulativeGroupedBulk.validate() } + + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -1749,26 +1782,14 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewFloatingUnitPrice) = unit.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 visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewFloatingBpsPrice) = bps.validity() + override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) = - bulkBps.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = + package_.validity() - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitMatrix(matrix: NewFloatingMatrixPrice) = matrix.validity() override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice @@ -1778,30 +1799,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() @@ -1814,6 +1835,10 @@ private constructor( groupedAllocation: NewFloatingGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -1822,18 +1847,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 @@ -1848,6 +1877,14 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + 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 } ) @@ -1857,53 +1894,115 @@ 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 && + 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 = /* 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, + 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}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - 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}" + 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}" + 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") } @@ -1912,27 +2011,14 @@ private constructor( @JvmStatic fun ofUnit(unit: NewFloatingUnitPrice) = Price(unit = unit) - @JvmStatic - fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) - - @JvmStatic - fun ofMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - @JvmStatic fun ofTiered(tiered: NewFloatingTieredPrice) = Price(tiered = tiered) - @JvmStatic - fun ofTieredBps(tieredBps: NewFloatingTieredBpsPrice) = Price(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: NewFloatingBpsPrice) = Price(bps = bps) + @JvmStatic fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) @JvmStatic - fun ofBulkBps(bulkBps: NewFloatingBulkBpsPrice) = Price(bulkBps = bulkBps) + fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) - @JvmStatic fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount( @@ -1943,33 +2029,33 @@ private constructor( fun ofTieredPackage(tieredPackage: NewFloatingTieredPackagePrice) = Price(tieredPackage = tieredPackage) - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - @JvmStatic fun ofTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) @JvmStatic fun ofTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + @JvmStatic fun ofUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice) = Price(unitWithPercent = unitWithPercent) + @JvmStatic + fun ofMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic fun ofTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice @@ -1983,6 +2069,10 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice @@ -1993,20 +2083,26 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JvmStatic fun ofMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - @JvmStatic fun ofGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = Price(groupedTieredPackage = groupedTieredPackage) + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + @JvmStatic fun ofScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -2021,6 +2117,14 @@ private constructor( fun ofCumulativeGroupedBulk( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -2030,23 +2134,13 @@ 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 visitTieredBps(tieredBps: NewFloatingTieredBpsPrice): T - - fun visitBps(bps: NewFloatingBpsPrice): T + fun visitBulk(bulk: NewFloatingBulkPrice): T - fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice): T + fun visitPackage(package_: NewFloatingPackagePrice): T - fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitMatrix(matrix: NewFloatingMatrixPrice): T fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice @@ -2054,24 +2148,24 @@ private constructor( 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 @@ -2080,6 +2174,8 @@ private constructor( fun visitGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ): T @@ -2088,16 +2184,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 @@ -2110,6 +2212,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -2137,42 +2245,22 @@ 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) } - "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) } + "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, @@ -2189,6 +2277,14 @@ private constructor( ?.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, @@ -2197,20 +2293,12 @@ private constructor( ?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = 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" -> { @@ -2221,20 +2309,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" -> { @@ -2261,6 +2349,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, @@ -2277,20 +2373,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" -> { @@ -2301,6 +2397,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, @@ -2327,6 +2431,23 @@ private constructor( ?.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) @@ -2342,69 +2463,4985 @@ 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.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.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.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 equals(other: Any?): Boolean { - if (this === other) { - return true - } + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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(), + ) - 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 */ - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an 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 grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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) + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, filter, groupingKeys, price, priceId, additionalProperties) } - /* spotless:on */ + 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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( + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 { + if (this === other) { + return true + } + + return other is PriceEvaluation && + externalPriceId == other.externalPriceId && + filter == other.filter && + groupingKeys == other.groupingKeys && + price == other.price && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + externalPriceId, + filter, + groupingKeys, + price, + priceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2417,10 +7454,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-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt index 8df83229..0e4dddeb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PriceEvaluateMultipleResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -172,6 +173,7 @@ private constructor( (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val priceGroups: JsonField>, @@ -514,12 +516,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 @@ -532,12 +547,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-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt index e22c2a78..13808928 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt @@ -468,6 +468,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, @@ -865,13 +866,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() = @@ -883,10 +899,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-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index 425a39c4..d8d07128 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-java-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 @@ -460,6 +461,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, @@ -862,12 +864,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 @@ -876,6 +893,7 @@ private constructor( } class Event + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val eventName: JsonField, private val properties: JsonField, @@ -1302,12 +1320,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 @@ -1319,12 +1335,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 @@ -1333,6 +1362,7 @@ private constructor( } class PriceEvaluation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalPriceId: JsonField, private val filter: JsonField, @@ -1383,8 +1413,7 @@ private constructor( fun groupingKeys(): Optional> = groupingKeys.getOptional("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). @@ -1545,10 +1574,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)) /** Alias for calling [Builder.price] with `price.orElse(null)`. */ @@ -1566,33 +1592,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.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)) + /** 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)`. */ @@ -1603,20 +1614,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 @@ -1625,17 +1636,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)`. */ @@ -1650,6 +1660,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)`. @@ -1664,6 +1678,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)`. @@ -1671,16 +1692,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)`. @@ -1704,6 +1728,15 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** 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)) + /** The ID of a price to evaluate that exists in your Orb account. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1791,41 +1824,36 @@ private constructor( (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) - /** - * 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 tieredBps: NewFloatingTieredBpsPrice? = null, - private val bps: NewFloatingBpsPrice? = null, - private val bulkBps: NewFloatingBulkBpsPrice? = 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, @@ -1833,27 +1861,21 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = 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, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) @@ -1861,24 +1883,24 @@ private constructor( fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) - - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) - fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) fun tieredPackageWithMinimum(): Optional = Optional.ofNullable(tieredPackageWithMinimum) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -1888,21 +1910,27 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) - fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + fun scalableMatrixWithUnitPricing(): Optional = Optional.ofNullable(scalableMatrixWithUnitPricing) @@ -1914,56 +1942,58 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun isUnit(): Boolean = unit != null + fun minimum(): Optional = Optional.ofNullable(minimum) - fun isPackage(): Boolean = package_ != null + fun percent(): Optional = Optional.ofNullable(percent) - fun isMatrix(): Boolean = matrix != null + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != null + fun isMatrix(): Boolean = matrix != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null - fun isGroupedTiered(): Boolean = groupedTiered != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != 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 = @@ -1971,24 +2001,21 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") + fun isMinimum(): Boolean = minimum != null - fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") + fun isPercent(): Boolean = percent != null - fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") + fun isEventOutput(): Boolean = eventOutput != null - fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewFloatingTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewFloatingBpsPrice = bps.getOrThrow("bps") + fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") - fun asBulkBps(): NewFloatingBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") - fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -1996,24 +2023,24 @@ private constructor( 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") @@ -2023,21 +2050,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") @@ -2048,45 +2081,50 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): Optional = Optional.ofNullable(_json) 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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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 -> @@ -2095,6 +2133,9 @@ 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) } @@ -2111,38 +2152,20 @@ 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() } - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewFloatingBpsPrice) { - bps.validate() + override fun visitBulk(bulk: NewFloatingBulkPrice) { + bulk.validate() } - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) { - bulkBps.validate() + override fun visitPackage(package_: NewFloatingPackagePrice) { + package_.validate() } - override fun visitBulk(bulk: NewFloatingBulkPrice) { - bulk.validate() + override fun visitMatrix(matrix: NewFloatingMatrixPrice) { + matrix.validate() } override fun visitThresholdTotalAmount( @@ -2157,22 +2180,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( @@ -2181,18 +2204,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 ) { @@ -2211,6 +2234,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) { @@ -2223,16 +2252,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( @@ -2241,6 +2270,12 @@ private constructor( groupedTieredPackage.validate() } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -2260,6 +2295,18 @@ private constructor( ) { cumulativeGroupedBulk.validate() } + + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -2285,26 +2332,14 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewFloatingUnitPrice) = unit.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 visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewFloatingBpsPrice) = bps.validity() + override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) = - bulkBps.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = + package_.validity() - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitMatrix(matrix: NewFloatingMatrixPrice) = matrix.validity() override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice @@ -2314,30 +2349,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() @@ -2350,6 +2385,10 @@ private constructor( groupedAllocation: NewFloatingGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -2358,18 +2397,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 @@ -2384,6 +2427,14 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + 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 } ) @@ -2393,53 +2444,115 @@ 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 && + 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 = /* 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, + 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}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - 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}" + 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}" + 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") } @@ -2448,27 +2561,14 @@ private constructor( @JvmStatic fun ofUnit(unit: NewFloatingUnitPrice) = Price(unit = unit) - @JvmStatic - fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) - - @JvmStatic - fun ofMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - @JvmStatic fun ofTiered(tiered: NewFloatingTieredPrice) = Price(tiered = tiered) - @JvmStatic - fun ofTieredBps(tieredBps: NewFloatingTieredBpsPrice) = Price(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: NewFloatingBpsPrice) = Price(bps = bps) + @JvmStatic fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) @JvmStatic - fun ofBulkBps(bulkBps: NewFloatingBulkBpsPrice) = Price(bulkBps = bulkBps) + fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) - @JvmStatic fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount( @@ -2479,33 +2579,33 @@ private constructor( fun ofTieredPackage(tieredPackage: NewFloatingTieredPackagePrice) = Price(tieredPackage = tieredPackage) - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - @JvmStatic fun ofTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) @JvmStatic fun ofTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + @JvmStatic fun ofUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice) = Price(unitWithPercent = unitWithPercent) + @JvmStatic + fun ofMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic fun ofTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice @@ -2519,6 +2619,10 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice @@ -2529,20 +2633,26 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JvmStatic fun ofMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - @JvmStatic fun ofGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = Price(groupedTieredPackage = groupedTieredPackage) + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + @JvmStatic fun ofScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -2557,6 +2667,14 @@ private constructor( fun ofCumulativeGroupedBulk( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -2566,23 +2684,13 @@ 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 visitTieredBps(tieredBps: NewFloatingTieredBpsPrice): T - - fun visitBps(bps: NewFloatingBpsPrice): T + fun visitBulk(bulk: NewFloatingBulkPrice): T - fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice): T + fun visitPackage(package_: NewFloatingPackagePrice): T - fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitMatrix(matrix: NewFloatingMatrixPrice): T fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice @@ -2590,24 +2698,24 @@ private constructor( 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 @@ -2616,6 +2724,8 @@ private constructor( fun visitGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ): T @@ -2624,16 +2734,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 @@ -2646,6 +2762,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -2673,42 +2795,22 @@ 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) } - "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) } + "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, @@ -2725,6 +2827,14 @@ private constructor( ?.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, @@ -2733,20 +2843,12 @@ private constructor( ?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } - "max_group_tiered_package" -> { + "tiered_package_with_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_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" -> { @@ -2757,20 +2859,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" -> { @@ -2797,6 +2899,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, @@ -2813,20 +2923,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" -> { @@ -2837,6 +2947,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, @@ -2863,6 +2981,23 @@ private constructor( ?.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) @@ -2878,69 +3013,4985 @@ 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.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.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.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 equals(other: Any?): Boolean { - if (this === other) { - return true - } + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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(), + ) - 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 */ - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an 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 grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, filter, groupingKeys, price, priceId, additionalProperties) } - /* spotless:on */ + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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( + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 { + if (this === other) { + return true + } + + return other is PriceEvaluation && + externalPriceId == other.externalPriceId && + filter == other.filter && + groupingKeys == other.groupingKeys && + price == other.price && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + externalPriceId, + filter, + groupingKeys, + price, + priceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -2953,10 +8004,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-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt index aa97e71a..5f3e5d70 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PriceEvaluatePreviewEventsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -174,6 +175,7 @@ private constructor( (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val priceGroups: JsonField>, @@ -516,12 +518,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 @@ -534,12 +549,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-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt index aec7f52c..5da61080 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class PriceEvaluateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -177,12 +178,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-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt index 8eaf6741..90471ca6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt @@ -192,10 +192,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-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt index 98211957..db048139 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt @@ -270,6 +270,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, @@ -408,12 +409,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 @@ -515,12 +516,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 @@ -532,10 +531,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-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt index 90a4c0db..c935f434 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt @@ -176,10 +176,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-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index a37243be..5c9aa7ce 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -25,6 +25,7 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -509,27 +510,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.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)) + /** 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)) @@ -537,13 +529,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)`. @@ -577,6 +569,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)`. @@ -591,16 +587,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)) @@ -631,12 +630,14 @@ 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)) + + /** 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 start date of the price interval. This is the date that Orb starts billing for this @@ -797,12 +798,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-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt index e364ec84..211a09f1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt index 16f0bb3a..586d37bd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt @@ -134,10 +134,14 @@ private constructor( return true } - return /* spotless:off */ other is PriceListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is PriceListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "PriceListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt index 589da067..1ac46af3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class PriceListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -131,27 +132,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.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)) + /** 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)`. */ @@ -162,14 +154,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)`. @@ -205,6 +197,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)`. @@ -219,16 +215,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)`. */ @@ -261,12 +260,14 @@ 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)) + + /** 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)) fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -357,12 +358,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-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt index 6bf5acc1..bdba6942 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt @@ -207,10 +207,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-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt index 0abcc249..c2f697bd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt @@ -262,6 +262,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, @@ -400,12 +401,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 @@ -507,12 +508,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 @@ -524,10 +523,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-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt index 17e19971..dbbebab2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SubLineItemGrouping +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val key: JsonField, private val value: JsonField, @@ -196,12 +197,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-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt index 84a14264..7051e20f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class SubLineItemMatrixConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dimensionValues: JsonField>, private val additionalProperties: MutableMap, @@ -183,12 +184,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-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt index dd1abad3..f02d6ede 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt @@ -49,6 +49,7 @@ import kotlin.jvm.optionals.getOrNull * a recurring fee for the following period. */ class Subscription +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val activePlanPhaseOrder: JsonField, @@ -1658,10 +1659,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 { @@ -1852,12 +1856,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 @@ -1986,7 +1988,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() @@ -1999,12 +2001,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt index 807e108b..a869a43e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt @@ -65,7 +65,6 @@ import kotlin.jvm.optionals.getOrNull * `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 @@ -412,6 +411,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, @@ -682,12 +682,21 @@ 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 } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cancelOption, allowInvoiceCreditOrVoid, cancellationDate, additionalProperties) } - /* spotless:on */ + private val hashCode: Int by lazy { + Objects.hash( + cancelOption, + allowInvoiceCreditOrVoid, + cancellationDate, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode @@ -821,7 +830,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() @@ -834,10 +843,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt index 60e08f8d..3fb6beed 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyParams.kt @@ -43,7 +43,17 @@ private constructor( fun description(): Optional = 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(): Optional = 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). @@ -57,6 +67,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]. * @@ -119,6 +136,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() } @@ -138,7 +156,35 @@ 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?) + + /** Alias for calling [Builder.markAsPaid] with `markAsPaid.orElse(null)`. */ + fun markAsPaid(markAsPaid: Optional) = markAsPaid(markAsPaid.getOrNull()) + + /** + * 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) } @@ -305,8 +351,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val description: JsonField, + private val markAsPaid: JsonField, private val previouslyCollectedAmount: JsonField, private val additionalProperties: MutableMap, ) { @@ -316,10 +364,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. @@ -330,7 +381,17 @@ private constructor( fun description(): Optional = description.getOptional("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(): Optional = markAsPaid.getOptional("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). @@ -347,6 +408,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]. * @@ -379,12 +449,14 @@ 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() @JvmSynthetic internal fun from(body: Body) = apply { description = body.description + markAsPaid = body.markAsPaid previouslyCollectedAmount = body.previouslyCollectedAmount additionalProperties = body.additionalProperties.toMutableMap() } @@ -406,7 +478,35 @@ 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?) + + /** Alias for calling [Builder.markAsPaid] with `markAsPaid.orElse(null)`. */ + fun markAsPaid(markAsPaid: Optional) = markAsPaid(markAsPaid.getOrNull()) + + /** + * 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)) @@ -453,7 +553,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 @@ -464,6 +569,7 @@ private constructor( } description() + markAsPaid() previouslyCollectedAmount() validated = true } @@ -485,6 +591,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (description.asKnown().isPresent) 1 else 0) + + (if (markAsPaid.asKnown().isPresent) 1 else 0) + (if (previouslyCollectedAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -492,17 +599,21 @@ 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 && + markAsPaid == other.markAsPaid && + 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, 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 { @@ -510,10 +621,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt index 7e878365..af0e3739 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponse.kt @@ -25,6 +25,7 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -491,7 +492,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() @@ -504,12 +505,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt index ed360c5d..0ab635b3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelParams.kt @@ -228,10 +228,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt index 5bcfee6f..e7b5aeb2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponse.kt @@ -25,6 +25,7 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -491,7 +492,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() @@ -504,12 +505,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt index 6c2c2814..1474cc61 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt +++ b/orb-java-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, @@ -152,12 +153,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt index 46d0066e..733d3942 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveParams.kt @@ -199,10 +199,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt index b4304daa..c3584361 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponse.kt @@ -25,6 +25,7 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -491,7 +492,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() @@ -504,12 +505,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index f9c19fa4..687867ef 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -170,7 +170,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -215,7 +214,6 @@ import kotlin.jvm.optionals.getOrNull * ``` * * ### 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. @@ -1806,6 +1804,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>, @@ -3707,12 +3706,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 @@ -3721,6 +3790,7 @@ private constructor( } class AddAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val endDate: JsonField, @@ -4240,10 +4310,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 { @@ -4372,12 +4448,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 @@ -4386,6 +4467,7 @@ private constructor( } class AddPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val discounts: JsonField>, @@ -4506,7 +4588,7 @@ private constructor( fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("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). @@ -4842,7 +4924,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)) /** Alias for calling [Builder.price] with `price.orElse(null)`. */ @@ -4860,28 +4942,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.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)) + /** 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)`. */ @@ -4896,9 +4968,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 @@ -4907,10 +4986,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)`. */ @@ -4921,6 +5010,10 @@ private constructor( 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)`. @@ -4928,32 +5021,32 @@ private constructor( 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)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + 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 @@ -4964,40 +5057,36 @@ private constructor( /** * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** 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)) @@ -5122,31 +5211,38 @@ private constructor( (if (priceId.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - /** 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 tieredBps: NewSubscriptionTieredBpsPrice? = null, - private val bps: NewSubscriptionBpsPrice? = null, - private val bulkBps: NewSubscriptionBulkBpsPrice? = 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, @@ -5154,34 +5250,21 @@ 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 minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = - Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) @@ -5192,13 +5275,22 @@ private constructor( fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) fun packageWithAllocation(): Optional = Optional.ofNullable(packageWithAllocation) - fun tieredWithProration(): Optional = + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) fun unitWithProration(): Optional = @@ -5207,12 +5299,28 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + fun groupedWithMeteredMinimum(): + Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) fun scalableMatrixWithUnitPricing(): Optional = @@ -5225,43 +5333,22 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) - - fun groupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(groupedWithMeteredMinimum) - - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) - - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) - - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + fun minimum(): Optional = + Optional.ofNullable(minimum) - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + fun percent(): Optional = Optional.ofNullable(percent) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != null + fun isMatrix(): Boolean = matrix != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -5269,56 +5356,58 @@ private constructor( 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 isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMinimum(): Boolean = minimum != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isPercent(): Boolean = percent != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isEventOutput(): Boolean = eventOutput != 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 asTieredBps(): NewSubscriptionTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewSubscriptionBpsPrice = bps.getOrThrow("bps") + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") - fun asBulkBps(): NewSubscriptionBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -5329,13 +5418,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 = @@ -5344,12 +5442,27 @@ private constructor( fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - 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") @@ -5361,53 +5474,50 @@ private constructor( 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 asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asPercent(): Percent = percent.getOrThrow("percent") - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): Optional = Optional.ofNullable(_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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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 -> @@ -5416,19 +5526,9 @@ 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) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -5445,32 +5545,20 @@ 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() } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewSubscriptionBpsPrice) { - bps.validate() + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() } - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) { - bulkBps.validate() + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() } override fun visitThresholdTotalAmount( @@ -5491,10 +5579,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( @@ -5503,8 +5597,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() } @@ -5521,6 +5627,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice @@ -5528,30 +5640,28 @@ private constructor( groupedWithProratedMinimum.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice ) { - bulkWithProration.validate() + groupedWithMeteredMinimum.validate() } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) { - scalableMatrixWithUnitPricing.validate() + groupedWithMinMaxThresholds.validate() } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ) { - scalableMatrixWithTieredPricing.validate() + matrixWithDisplayName.validate() } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice ) { - cumulativeGroupedBulk.validate() + groupedTieredPackage.validate() } override fun visitMaxGroupTieredPackage( @@ -5560,40 +5670,36 @@ private constructor( maxGroupTieredPackage.validate() } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice ) { - groupedWithMeteredMinimum.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice ) { - matrixWithDisplayName.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) { - groupedTieredPackage.validate() + cumulativeGroupedBulk.validate() } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + override fun visitPercent(percent: Percent) { + percent.validate() } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() } } ) @@ -5620,24 +5726,16 @@ private constructor( 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 visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewSubscriptionBpsPrice) = bps.validity() + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = - bulkBps.validity() + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() override fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice @@ -5651,16 +5749,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( @@ -5671,14 +5781,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: @@ -5694,33 +5824,13 @@ 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 visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5731,53 +5841,115 @@ 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 */ + 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 = /* 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 */ + 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}" - 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}" + 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}" + 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") } @@ -5786,23 +5958,14 @@ private constructor( @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) - @JvmStatic - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) - @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) - @JvmStatic - fun ofTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - Price(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: NewSubscriptionBpsPrice) = Price(bps = bps) + @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) @JvmStatic - fun ofBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = Price(bulkBps = bulkBps) + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount( @@ -5818,8 +5981,13 @@ private constructor( Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic fun ofPackageWithAllocation( @@ -5827,9 +5995,17 @@ private constructor( ) = Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) @JvmStatic fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = @@ -5839,30 +6015,34 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) @JvmStatic fun ofMaxGroupTieredPackage( @@ -5870,33 +6050,29 @@ private constructor( ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) @JvmStatic - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -5906,19 +6082,13 @@ private constructor( fun visitUnit(unit: NewSubscriptionUnitPrice): T - fun visitPackage(package_: NewSubscriptionPackagePrice): T - - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T - fun visitTiered(tiered: NewSubscriptionTieredPrice): T - fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice): T - - fun visitBps(bps: NewSubscriptionBpsPrice): T + fun visitBulk(bulk: NewSubscriptionBulkPrice): T - fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice): T + fun visitPackage(package_: NewSubscriptionPackagePrice): T - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice @@ -5930,16 +6100,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 @@ -5948,52 +6126,52 @@ private constructor( groupedAllocation: NewSubscriptionGroupedAllocationPrice ): T + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice ): T - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice ): T - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ): T - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice ): T fun visitMaxGroupTieredPackage( maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice ): T - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice ): T - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice ): T - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + fun visitPercent(percent: Percent): T - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun visitEventOutput(eventOutput: EventOutput): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -6022,20 +6200,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) - } "tiered" -> { return tryDeserialize( node, @@ -6043,27 +6207,23 @@ private constructor( ) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "package" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bps = it, _json = json) } ?: Price(_json = json) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) } - "bulk_bps" -> { + "matrix" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) } "threshold_total_amount" -> { return tryDeserialize( @@ -6089,12 +6249,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" -> { @@ -6105,11 +6273,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) } @@ -6129,6 +6310,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, @@ -6137,40 +6326,36 @@ private constructor( ?.let { Price(groupedWithProratedMinimum = it, _json = json) } ?: Price(_json = json) } - "bulk_with_proration" -> { + "grouped_with_metered_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(bulkWithProration = it, _json = json) } + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } - "scalable_matrix_with_unit_pricing" -> { + "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } ?: Price(_json = json) } - "scalable_matrix_with_tiered_pricing" -> { + "matrix_with_display_name" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } - "cumulative_grouped_bulk" -> { + "grouped_tiered_package" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?.let { Price(groupedTieredPackage = it, _json = json) } ?: Price(_json = json) } "max_group_tiered_package" -> { @@ -6181,53 +6366,50 @@ private constructor( ?.let { Price(maxGroupTieredPackage = it, _json = json) } ?: Price(_json = json) } - "grouped_with_metered_minimum" -> { + "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } ?: Price(_json = json) } - "matrix_with_display_name" -> { + "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } ?: Price(_json = json) } - "grouped_tiered_package" -> { + "cumulative_grouped_bulk" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedTieredPackage = it, _json = json) } + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "matrix_with_allocation" -> { + "minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) } } @@ -6244,3114 +6426,17131 @@ 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.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.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.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 equals(other: Any?): Boolean { - if (this === other) { - return true - } + 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(), + ) - 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 */ - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, discounts, endDate, externalPriceId, maximumAmount, minimumAmount, planPhaseOrder, price, priceId, startDate, additionalProperties) } - /* spotless:on */ + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun hashCode(): Int = hashCode + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - 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 name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - @Deprecated("deprecated") - class ExternalMarketplace - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * 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") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the 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(): Optional = + billableMetricId.getOptional("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(): Optional = + billedInAdvance.getOptional("billed_in_advance") - @JvmField 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(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - @JvmField 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(): Optional = + conversionRate.getOptional("conversion_rate") - @JvmField 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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - @JvmStatic 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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("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().orElseThrow { 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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value 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 [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 - return /* spotless:off */ other is ExternalMarketplace && value == other.value /* spotless:on */ - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * 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]. */ - @JvmStatic 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 - @JvmSynthetic - 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 + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** 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() + + @JvmSynthetic + 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 an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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(): Metadata = 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - validated = true - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * 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. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - class RemoveAdjustment - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * 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 putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * 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 removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 toBuilder() = Builder().from(this) + private var validated: Boolean = false - companion object { + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - @JvmSynthetic - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** 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, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * 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 an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> 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 additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(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 putAdditionalProperty(key: String, value: JsonValue) = apply { - 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + private var validated: Boolean = false - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + known() + validated = true + } - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + return other is Cadence && value == other.value + } - adjustmentId() - 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. - */ - @JvmSynthetic - internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + /** 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 equals(other: Any?): Boolean { - if (this === other) { - return true - } + @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) + } - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ - } + @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: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /* spotless:on */ + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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() } + } - override fun hashCode(): Int = hashCode + /** + * 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 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(): Optional = externalPriceId.getOptional("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(): Optional = priceId.getOptional("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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + 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 + private var validated: Boolean = false - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + tiers().forEach { it.validate() } + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.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) + } - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - @JvmStatic fun builder() = Builder() - } + @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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var validated: Boolean = false - @JvmSynthetic - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + tierLowerBound() + unitAmount() + validated = true + } - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + 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(tierLowerBound, unitAmount, additionalProperties) + } - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + override fun hashCode(): Int = hashCode - /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ - fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$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 } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private val hashCode: Int by lazy { Objects.hash(tiers, 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() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - 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`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * 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()) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + companion object { - externalPriceId() - priceId() - validated = true - } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (priceId.asKnown().isPresent) 1 else 0) + private var additionalProperties: MutableMap = + mutableMapOf() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - return /* spotless:off */ other is RemovePrice && externalPriceId == other.externalPriceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, priceId, additionalProperties) } - /* spotless:on */ + 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 [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. - * - * @throws OrbInvalidDataException if 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(): Metadata = apply { + if (validated) { + return@apply + } - /** - * 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 + validated = true + } - /** - * 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 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. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun toBuilder() = Builder().from(this) + return other is Metadata && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun hashCode(): Int = hashCode - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - 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 + } - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + 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 + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + 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, + ) + } - /** - * 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 hashCode(): Int = hashCode - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + 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}" + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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() + 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, + ) { + + @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(), ) - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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() - ) + /** + * 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" + ) - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected 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 calling [adjustment] with the following: - * ```java - * 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() - ) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_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 - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(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(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .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 - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - adjustment().validate() - replacesAdjustmentId() - 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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("metadata") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - /** 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 [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + /** + * 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 usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + /** + * Returns the raw JSON value of [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 amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + /** + * Returns the raw JSON value 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 minimum(): Optional = Optional.ofNullable(minimum) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * 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 maximum(): Optional = Optional.ofNullable(maximum) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * 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 isPercentageDiscount(): Boolean = percentageDiscount != 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 isUsageDiscount(): Boolean = usageDiscount != 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 isAmountDiscount(): Boolean = amountDiscount != 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 isMinimum(): Boolean = minimum != 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 isMaximum(): Boolean = maximum != 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 asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("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 asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("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 asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("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 asMinimum(): NewMinimum = minimum.getOrThrow("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 asMaximum(): NewMaximum = maximum.getOrThrow("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 _json(): Optional = Optional.ofNullable(_json) + /** + * Returns the raw JSON value of [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 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) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply + @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: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } - - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() + /** 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() + + @JvmSynthetic + 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 visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * 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 visitMaximum(maximum: NewMaximum) { - maximum.validate() - } + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - ) - validated = true - } - 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. + */ + 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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 visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * 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 visitMinimum(minimum: NewMinimum) = minimum.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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 visitMaximum(maximum: NewMaximum) = maximum.validity() + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 unknown(json: JsonValue?) = 0 + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ - } + /** + * Within each billing cycle, specifies the 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 hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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(): 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) + } - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - @JvmStatic 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(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T - - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T - - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T - - fun visitMinimum(minimum: NewMinimum): T + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + 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. + * 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") - } - } + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_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") } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_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().orElseThrow { + OrbInvalidDataException("Value is not a String") } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } + + known() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is Cadence && value == other.value } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** 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, + ) { - return /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ - } + @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) + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + @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: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun hashCode(): Int = hashCode + /** 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() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } + /** 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 + } - 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, - ) { + /** 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 + } - @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 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 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 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 + } - /** - * 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(): Optional = - allocationPrice.getOptional("allocation_price") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * [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(): Optional> = discounts.getOptional("discounts") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * 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(): Optional = externalPriceId.getOptional("external_price_id") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * 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(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(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(): Optional = maximumAmount.getOptional("maximum_amount") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * [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(): Optional = minimumAmount.getOptional("minimum_amount") + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - /** - * 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(): Optional = price.getOptional("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(): Optional = priceId.getOptional("price_id") + fun validate(): GroupedWithMinMaxThresholdsConfig = 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 + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + 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]. - * - * 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 a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + 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 GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + 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( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + 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() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, 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 + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire 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 [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = 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 [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - companion object { + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - 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) + } - @JvmSynthetic - 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) + } - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + /** + * 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.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 - } + private var validated: Boolean = false - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** Alias for calling [Builder.discounts] with `discounts.orElse(null)`. */ - @Deprecated("deprecated") - fun discounts(discounts: Optional>) = - discounts(discounts.getOrNull()) + validated = 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() } - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * 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) - } - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + return other is Metadata && + 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(additionalProperties) } - /** The new quantity of the price, if the price is a fixed price. */ - 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() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + 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 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 + } - /** - * [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 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, + ) + } - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * 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() = + "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}" } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + 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(), + ) - /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(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") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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( + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 { + + @JvmField val GOOGLE = of("google") + + @JvmField val AWS = of("aws") + + @JvmField val AZURE = of("azure") + + @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): ExternalMarketplace = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + + 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(): Optional = externalPriceId.getOptional("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(): Optional = priceId.getOptional("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]. */ + @JvmStatic 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() + + @JvmSynthetic + 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 [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. 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)) + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + + /** + * 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + 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(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic 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().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + 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(): Optional = + allocationPrice.getOptional("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(): Optional> = discounts.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = maximumAmount.getOptional("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(): Optional = minimumAmount.getOptional("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(): Optional = price.getOptional("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(): Optional = priceId.getOptional("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: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.discounts] with `discounts.orElse(null)`. */ + @Deprecated("deprecated") + fun discounts(discounts: Optional>) = + discounts(discounts.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. 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)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ @Deprecated("deprecated") fun minimumAmount(minimumAmount: Optional) = minimumAmount(minimumAmount.getOrNull()) - /** - * 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 [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)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * 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.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)) + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + + /** + * 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: + * ```java + * .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().ifPresent { it.validate() } + discounts().ifPresent { it.forEach { it.validate() } } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + /** 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(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): + Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): + Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun minimum(): Optional = + Optional.ofNullable(minimum) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + @JvmStatic + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + 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().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + 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}" } - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + 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, + ) { + + @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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + 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: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: NewSubscriptionTieredBpsPrice) = - price(Price.ofTieredBps(tieredBps)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: NewSubscriptionBpsPrice) = price(Price.ofBps(bps)) + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewSubscriptionBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> 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.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + known() + validated = true + } - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + return other is Cadence && value == other.value + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + override fun hashCode() = value.hashCode() - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + override fun toString() = value.toString() + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** 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 [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + @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) + } - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + @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: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** 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() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** 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 + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** 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 id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** 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 + } - /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ - fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + /** 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 + } - /** - * 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 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .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 - private var validated: Boolean = false + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - discounts().ifPresent { it.forEach { it.validate() } } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price().ifPresent { it.validate() } - priceId() - 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + 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. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) + - (if (priceId.asKnown().isPresent) 1 else 0) + 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, + ) + } - /** 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, - ) { + override fun hashCode(): Int = hashCode - fun unit(): Optional = Optional.ofNullable(unit) + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } - fun package_(): Optional = Optional.ofNullable(package_) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire 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 matrix(): Optional = Optional.ofNullable(matrix) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun tiered(): Optional = Optional.ofNullable(tiered) + fun toBuilder() = Builder().from(this) - fun tieredBps(): Optional = - Optional.ofNullable(tieredBps) + companion object { - fun bps(): Optional = Optional.ofNullable(bps) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun bulk(): Optional = Optional.ofNullable(bulk) + private var additionalProperties: MutableMap = + mutableMapOf() - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + private var validated: Boolean = false - fun groupedWithProratedMinimum(): - Optional = - Optional.ofNullable(groupedWithProratedMinimum) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + validated = true + } - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun groupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + override fun hashCode(): Int = hashCode - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + 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 groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + 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 isUnit(): Boolean = unit != null + override fun hashCode(): Int = hashCode - fun isPackage(): Boolean = package_ != 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 isMatrix(): Boolean = matrix != null + 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(), + ) - fun isTiered(): Boolean = tiered != 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") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected 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 isTieredBps(): Boolean = tieredBps != null + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 isBps(): Boolean = bps != 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 isBulkBps(): Boolean = bulkBps != null + /** + * 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") - fun isBulk(): Boolean = bulk != 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(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != 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(): Optional = + billedInAdvance.getOptional("billed_in_advance") - fun isTieredPackage(): Boolean = tieredPackage != 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(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != 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(): Optional = + conversionRate.getOptional("conversion_rate") - fun isUnitWithPercent(): Boolean = unitWithPercent != 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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun isPackageWithAllocation(): Boolean = packageWithAllocation != 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(): Optional = currency.getOptional("currency") - fun isTieredWithProration(): Boolean = tieredWithProration != 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(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun isUnitWithProration(): Boolean = unitWithProration != 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(): Optional = + externalPriceId.getOptional("external_price_id") - fun isGroupedAllocation(): Boolean = groupedAllocation != 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(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != 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(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun isBulkWithProration(): Boolean = bulkWithProration != 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(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != 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(): Optional = metadata.getOptional("metadata") - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != 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(): Optional = referenceId.getOptional("reference_id") - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != 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 isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != 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 isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != 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 isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * 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 isGroupedTieredPackage(): Boolean = groupedTieredPackage != 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 isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != 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 isGroupedTiered(): Boolean = groupedTiered != 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(): NewSubscriptionUnitPrice = 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(): NewSubscriptionPackagePrice = 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(): NewSubscriptionMatrixPrice = 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(): NewSubscriptionTieredPrice = 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 asTieredBps(): NewSubscriptionTieredBpsPrice = tieredBps.getOrThrow("tieredBps") + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * 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 asBps(): NewSubscriptionBpsPrice = bps.getOrThrow("bps") + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * 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 asBulkBps(): NewSubscriptionBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * 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 asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + /** + * Returns the raw JSON value 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 asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Returns the raw JSON value of [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 asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + @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: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** 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() + + @JvmSynthetic + 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 asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** 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: + * ```java + * 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 + } - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * The 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 [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * If the Price represents a fixed cost, the price 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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 asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Within each billing cycle, specifies the 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") + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + 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 asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - 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 + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), ) - 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) } - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + fun validate(): Percent = apply { + if (validated) { + return@apply + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) { - tieredBps.validate() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitBps(bps: NewSubscriptionBpsPrice) { - bps.validate() - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) { - bulkBps.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + private var validated: Boolean = false - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() + fun validate(): Cadence = apply { + if (validated) { + return@apply } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + known() + validated = true + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) { - tieredWithProration.validate() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + return other is Cadence && value == other.value + } - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + override fun hashCode() = value.hashCode() - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + override fun toString() = value.toString() + } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + @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) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + @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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() + /** 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) } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + 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. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + percent() + validated = true + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - tieredBps.validity() + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - override fun visitBps(bps: NewSubscriptionBpsPrice) = bps.validity() + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = - bulkBps.validity() + override fun hashCode(): Int = hashCode - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.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 visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + fun toBuilder() = Builder().from(this) - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + companion object { - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = tieredWithProration.validity() + /** A builder for [Metadata]. */ + class Builder internal constructor() { - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.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 visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * 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 visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + private var validated: Boolean = false - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + validated = true + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.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 + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - 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 equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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 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 + } - 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") + 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 { + override fun hashCode(): Int = hashCode - @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + 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}" + } - @JvmStatic - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + 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(), + ) - @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** + * 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") - @JvmStatic - fun ofTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - Price(tieredBps = tieredBps) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JvmStatic fun ofBps(bps: NewSubscriptionBpsPrice) = Price(bps = bps) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - @JvmStatic - fun ofBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = Price(bulkBps = bulkBps) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - @JvmStatic - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - @JvmStatic - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - @JvmStatic - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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 - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = 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 - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - @JvmStatic - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JvmStatic - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = 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 - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * 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 [invoiceGroupingKey]. + * + * 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 visitUnit(unit: NewSubscriptionUnitPrice): 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 - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** + * Returns the raw JSON value 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 visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** + * Returns the raw JSON value of [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 visitTiered(tiered: NewSubscriptionTieredPrice): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice): T + @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: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun visitBps(bps: NewSubscriptionBpsPrice): T + /** 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() + + @JvmSynthetic + 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 visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice): T + /** 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 + } - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): 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. + */ + 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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 visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ): T + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + /** + * Within each billing cycle, specifies the 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 visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + private var validated: Boolean = false - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - internal class Deserializer : BaseDeserializer(Price::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): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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 (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) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "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) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = 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().orElseThrow { + OrbInvalidDataException("Value is not a String") } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + known() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = 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 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + /** 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 } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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 } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = 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) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = 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 [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "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) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = 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 } - "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. + */ + @JvmSynthetic + internal 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 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}" } } @@ -9360,12 +23559,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 @@ -9378,10 +23598,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt index 390c1717..4fe0b591 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt @@ -392,7 +392,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() @@ -405,10 +405,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt index f5fc0df0..fb2a57cf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class SubscriptionFetchCostsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -179,12 +180,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt index e1795704..fbe4b8fa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt @@ -184,10 +184,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt index a89ad92b..14d7195e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt @@ -126,10 +126,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt index 97f7efc3..5bd5c3bd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt @@ -141,10 +141,14 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionFetchSchedulePageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is SubscriptionFetchSchedulePageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "SubscriptionFetchSchedulePageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt index 58eecc46..068ffead 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class SubscriptionFetchSchedulePageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -225,12 +226,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt index ac89bdd3..75f6fc95 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt @@ -298,10 +298,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt index 4b03eb91..13cb8208 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SubscriptionFetchScheduleResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val endDate: JsonField, @@ -274,6 +275,7 @@ private constructor( (if (startDate.asKnown().isPresent) 1 else 0) class Plan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val externalPlanId: JsonField, @@ -510,12 +512,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 @@ -528,12 +534,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt index 6c9218f3..29934eb7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt @@ -26,7 +26,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -43,7 +42,6 @@ import kotlin.jvm.optionals.getOrNull * 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, @@ -55,7 +53,6 @@ import kotlin.jvm.optionals.getOrNull * - 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. @@ -104,7 +101,6 @@ import kotlin.jvm.optionals.getOrNull * ``` * * ## 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. * @@ -159,7 +155,6 @@ import kotlin.jvm.optionals.getOrNull * ``` * * ## 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 @@ -178,7 +173,6 @@ import kotlin.jvm.optionals.getOrNull * 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`, @@ -656,7 +650,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() @@ -785,7 +779,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() @@ -798,10 +792,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt index 8619ff64..75bd0b97 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt @@ -122,10 +122,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt index 13d6d2ab..4c0e2829 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt @@ -135,10 +135,14 @@ private constructor( return true } - return /* spotless:off */ other is SubscriptionListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + return other is SubscriptionListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = "SubscriptionListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt index d6b3e6a0..eb44b0f4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt @@ -35,7 +35,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, @@ -59,9 +61,13 @@ private constructor( fun externalCustomerId(): Optional> = Optional.ofNullable(externalCustomerId) + fun externalPlanId(): Optional = Optional.ofNullable(externalPlanId) + /** The number of items to fetch. Defaults to 20. */ fun limit(): Optional = Optional.ofNullable(limit) + fun planId(): Optional = Optional.ofNullable(planId) + fun status(): Optional = Optional.ofNullable(status) /** Additional headers to send with the request. */ @@ -90,7 +96,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() @@ -104,7 +112,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() @@ -179,6 +189,12 @@ private constructor( (this.externalCustomerId ?: mutableListOf()).apply { add(externalCustomerId) } } + fun externalPlanId(externalPlanId: String?) = apply { this.externalPlanId = externalPlanId } + + /** Alias for calling [Builder.externalPlanId] with `externalPlanId.orElse(null)`. */ + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.getOrNull()) + /** The number of items to fetch. Defaults to 20. */ fun limit(limit: Long?) = apply { this.limit = limit } @@ -192,6 +208,11 @@ private constructor( /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) + fun planId(planId: String?) = apply { this.planId = planId } + + /** Alias for calling [Builder.planId] with `planId.orElse(null)`. */ + fun planId(planId: Optional) = planId(planId.getOrNull()) + fun status(status: Status?) = apply { this.status = status } /** Alias for calling [Builder.status] with `status.orElse(null)`. */ @@ -309,7 +330,9 @@ private constructor( cursor, customerId?.toImmutable(), externalCustomerId?.toImmutable(), + externalPlanId, limit, + planId, status, additionalHeaders.build(), additionalQueryParams.build(), @@ -336,7 +359,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) } @@ -464,7 +489,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() @@ -477,11 +502,39 @@ 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 && + externalPlanId == other.externalPlanId && + limit == other.limit && + planId == other.planId && + 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, + 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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt index b1ecd847..88929fc8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt +++ b/orb-java-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, @@ -152,12 +153,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 952b32f0..6326b56f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -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 @@ -83,7 +84,6 @@ import kotlin.jvm.optionals.getOrNull * 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 @@ -511,6 +511,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>, @@ -884,12 +885,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 @@ -898,6 +912,7 @@ private constructor( } class Add + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val startDate: JsonField, private val allocationPrice: JsonField, @@ -1044,7 +1059,7 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). @@ -1525,7 +1540,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)) /** Alias for calling [Builder.price] with `price.orElse(null)`. */ @@ -1543,33 +1558,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.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)) + /** 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)`. */ @@ -1580,20 +1580,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 @@ -1602,17 +1602,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)`. */ @@ -1627,6 +1626,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)`. @@ -1641,6 +1644,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)`. @@ -1648,16 +1658,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)`. @@ -1681,6 +1694,15 @@ private constructor( fun price(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** 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)) + /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1928,10 +1950,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 { @@ -2119,10 +2143,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 { @@ -2217,6 +2244,7 @@ private constructor( } class Amount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountDiscount: JsonField, private val discountType: JsonValue, @@ -2417,12 +2445,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 @@ -2431,6 +2462,7 @@ private constructor( } class Percentage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonValue, private val percentageDiscount: JsonField, @@ -2636,12 +2668,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 @@ -2650,6 +2685,7 @@ private constructor( } class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonValue, private val usageDiscount: JsonField, @@ -2854,12 +2890,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 @@ -2959,10 +2998,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 { @@ -3055,6 +3096,7 @@ private constructor( } class FixedFeeQuantityTransition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val effectiveDate: JsonField, private val quantity: JsonField, @@ -3255,12 +3297,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 @@ -3268,38 +3313,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 tieredBps: NewFloatingTieredBpsPrice? = null, - private val bps: NewFloatingBpsPrice? = null, - private val bulkBps: NewFloatingBulkBpsPrice? = 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, @@ -3307,27 +3350,21 @@ private constructor( NewFloatingScalableMatrixWithTieredPricingPrice? = 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, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) @@ -3335,24 +3372,24 @@ private constructor( fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) - - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) - fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) fun tieredPackageWithMinimum(): Optional = Optional.ofNullable(tieredPackageWithMinimum) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -3362,21 +3399,27 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) - fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + fun scalableMatrixWithUnitPricing(): Optional = Optional.ofNullable(scalableMatrixWithUnitPricing) @@ -3388,56 +3431,58 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun isUnit(): Boolean = unit != null + fun minimum(): Optional = Optional.ofNullable(minimum) - fun isPackage(): Boolean = package_ != null + fun percent(): Optional = Optional.ofNullable(percent) - fun isMatrix(): Boolean = matrix != null + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isUnit(): Boolean = unit != null fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != null + fun isMatrix(): Boolean = matrix != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null fun isTieredPackage(): Boolean = tieredPackage != null - fun isGroupedTiered(): Boolean = groupedTiered != null - - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != 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 = @@ -3445,24 +3490,21 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") + fun isMinimum(): Boolean = minimum != null - fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") + fun isPercent(): Boolean = percent != null - fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") + fun isEventOutput(): Boolean = eventOutput != null - fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asUnit(): NewFloatingUnitPrice = unit.getOrThrow("unit") fun asTiered(): NewFloatingTieredPrice = tiered.getOrThrow("tiered") - fun asTieredBps(): NewFloatingTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewFloatingBpsPrice = bps.getOrThrow("bps") + fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") - fun asBulkBps(): NewFloatingBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asPackage(): NewFloatingPackagePrice = package_.getOrThrow("package_") - fun asBulk(): NewFloatingBulkPrice = bulk.getOrThrow("bulk") + fun asMatrix(): NewFloatingMatrixPrice = matrix.getOrThrow("matrix") fun asThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -3470,24 +3512,24 @@ private constructor( 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") @@ -3497,21 +3539,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") @@ -3522,45 +3570,50 @@ private constructor( fun asCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + fun asMinimum(): NewFloatingMinimumCompositePrice = minimum.getOrThrow("minimum") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun _json(): Optional = Optional.ofNullable(_json) 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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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 -> @@ -3569,6 +3622,9 @@ 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) } @@ -3585,38 +3641,20 @@ 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() } - override fun visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewFloatingBpsPrice) { - bps.validate() + override fun visitBulk(bulk: NewFloatingBulkPrice) { + bulk.validate() } - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) { - bulkBps.validate() + override fun visitPackage(package_: NewFloatingPackagePrice) { + package_.validate() } - override fun visitBulk(bulk: NewFloatingBulkPrice) { - bulk.validate() + override fun visitMatrix(matrix: NewFloatingMatrixPrice) { + matrix.validate() } override fun visitThresholdTotalAmount( @@ -3631,22 +3669,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( @@ -3655,18 +3693,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 ) { @@ -3685,6 +3723,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) { @@ -3697,16 +3741,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( @@ -3715,6 +3759,12 @@ private constructor( groupedTieredPackage.validate() } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + override fun visitScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -3734,6 +3784,18 @@ private constructor( ) { cumulativeGroupedBulk.validate() } + + override fun visitMinimum(minimum: NewFloatingMinimumCompositePrice) { + minimum.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } } ) validated = true @@ -3759,26 +3821,14 @@ private constructor( object : Visitor { override fun visitUnit(unit: NewFloatingUnitPrice) = unit.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 visitTieredBps(tieredBps: NewFloatingTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewFloatingBpsPrice) = bps.validity() + override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() - override fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice) = - bulkBps.validity() + override fun visitPackage(package_: NewFloatingPackagePrice) = + package_.validity() - override fun visitBulk(bulk: NewFloatingBulkPrice) = bulk.validity() + override fun visitMatrix(matrix: NewFloatingMatrixPrice) = matrix.validity() override fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice @@ -3788,30 +3838,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() @@ -3824,6 +3874,10 @@ private constructor( groupedAllocation: NewFloatingGroupedAllocationPrice ) = groupedAllocation.validity() + override fun visitBulkWithProration( + bulkWithProration: NewFloatingBulkWithProrationPrice + ) = bulkWithProration.validity() + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ) = groupedWithProratedMinimum.validity() @@ -3832,18 +3886,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 @@ -3858,6 +3916,14 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = cumulativeGroupedBulk.validity() + 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 } ) @@ -3867,53 +3933,115 @@ 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 && + 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}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - 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}" + 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}" + 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") } @@ -3922,27 +4050,14 @@ private constructor( @JvmStatic fun ofUnit(unit: NewFloatingUnitPrice) = Price(unit = unit) - @JvmStatic - fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) - - @JvmStatic - fun ofMatrixWithAllocation( - matrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - @JvmStatic fun ofTiered(tiered: NewFloatingTieredPrice) = Price(tiered = tiered) - @JvmStatic - fun ofTieredBps(tieredBps: NewFloatingTieredBpsPrice) = Price(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: NewFloatingBpsPrice) = Price(bps = bps) + @JvmStatic fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) @JvmStatic - fun ofBulkBps(bulkBps: NewFloatingBulkBpsPrice) = Price(bulkBps = bulkBps) + fun ofPackage(package_: NewFloatingPackagePrice) = Price(package_ = package_) - @JvmStatic fun ofBulk(bulk: NewFloatingBulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: NewFloatingMatrixPrice) = Price(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount( @@ -3953,33 +4068,33 @@ private constructor( fun ofTieredPackage(tieredPackage: NewFloatingTieredPackagePrice) = Price(tieredPackage = tieredPackage) - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - @JvmStatic fun ofTieredWithMinimum(tieredWithMinimum: NewFloatingTieredWithMinimumPrice) = Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofGroupedTiered(groupedTiered: NewFloatingGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) @JvmStatic fun ofTieredPackageWithMinimum( tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + @JvmStatic fun ofUnitWithPercent(unitWithPercent: NewFloatingUnitWithPercentPrice) = Price(unitWithPercent = unitWithPercent) + @JvmStatic + fun ofMatrixWithAllocation( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic fun ofTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice @@ -3993,6 +4108,10 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice @@ -4003,20 +4122,26 @@ private constructor( groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + @JvmStatic fun ofMatrixWithDisplayName( matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice ) = Price(matrixWithDisplayName = matrixWithDisplayName) - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) - @JvmStatic fun ofGroupedTieredPackage( groupedTieredPackage: NewFloatingGroupedTieredPackagePrice ) = Price(groupedTieredPackage = groupedTieredPackage) + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + @JvmStatic fun ofScalableMatrixWithUnitPricing( scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice @@ -4031,6 +4156,14 @@ private constructor( fun ofCumulativeGroupedBulk( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofMinimum(minimum: NewFloatingMinimumCompositePrice) = Price(minimum = minimum) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -4040,23 +4173,13 @@ 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 visitTieredBps(tieredBps: NewFloatingTieredBpsPrice): T - - fun visitBps(bps: NewFloatingBpsPrice): T + fun visitBulk(bulk: NewFloatingBulkPrice): T - fun visitBulkBps(bulkBps: NewFloatingBulkBpsPrice): T + fun visitPackage(package_: NewFloatingPackagePrice): T - fun visitBulk(bulk: NewFloatingBulkPrice): T + fun visitMatrix(matrix: NewFloatingMatrixPrice): T fun visitThresholdTotalAmount( thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice @@ -4064,24 +4187,24 @@ private constructor( 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 @@ -4090,6 +4213,8 @@ private constructor( fun visitGroupedAllocation(groupedAllocation: NewFloatingGroupedAllocationPrice): T + fun visitBulkWithProration(bulkWithProration: NewFloatingBulkWithProrationPrice): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice ): T @@ -4098,16 +4223,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 @@ -4120,6 +4251,12 @@ private constructor( cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice ): T + fun visitMinimum(minimum: NewFloatingMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + /** * Maps an unknown variant of [Price] to a value of type [T]. * @@ -4147,42 +4284,22 @@ 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) } - "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) } + "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, @@ -4199,28 +4316,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" -> { @@ -4231,20 +4348,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" -> { @@ -4271,6 +4388,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, @@ -4287,20 +4412,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" -> { @@ -4311,6 +4436,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, @@ -4337,6 +4470,23 @@ private constructor( ?.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) @@ -4352,102 +4502,5029 @@ 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.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.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.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 equals(other: Any?): Boolean { - if (this === other) { - return true - } + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 /* 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 */ - } + @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(), + ) - /* 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 */ + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an 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}" - } + /** + * 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" + ) - 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") + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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( + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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: + * ```java + * .cadence() + * .currency() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 { + 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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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 - startDate: JsonField = JsonMissing.of(), + adjustmentId: JsonField = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), - ) : this(adjustment, startDate, endDate, 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") + ) : this(startDate, adjustment, adjustmentId, endDate, mutableMapOf()) /** * The start date of the adjustment interval. This is the date that the adjustment will @@ -4460,6 +9537,24 @@ private constructor( */ 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(): Optional = adjustment.getOptional("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(): Optional = adjustmentId.getOptional("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 @@ -4471,6 +9566,15 @@ private constructor( */ fun endDate(): Optional = endDate.getOptional("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]. * @@ -4481,13 +9585,14 @@ private constructor( fun _adjustment(): JsonField = adjustment /** - * Returns the raw JSON value of [startDate]. + * Returns the raw JSON value of [adjustmentId]. * - * Unlike [startDate], 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("start_date") + @JsonProperty("adjustment_id") @ExcludeMissing - fun _startDate(): JsonField = startDate + fun _adjustmentId(): JsonField = adjustmentId /** * Returns the raw JSON value of [endDate]. @@ -4515,7 +9620,6 @@ private constructor( * * The following fields are required: * ```java - * .adjustment() * .startDate() * ``` */ @@ -4525,21 +9629,53 @@ 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() @JvmSynthetic 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)) + + /** Alias for calling [Builder.adjustment] with `adjustment.orElse(null)`. */ + fun adjustment(adjustment: Optional) = adjustment(adjustment.getOrNull()) /** * Sets [Builder.adjustment] to an arbitrary JSON value. @@ -4644,31 +9780,27 @@ 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)) + + /** Alias for calling [Builder.adjustmentId] with `adjustmentId.orElse(null)`. */ + fun adjustmentId(adjustmentId: Optional) = + adjustmentId(adjustmentId.getOrNull()) /** - * 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 @@ -4726,7 +9858,6 @@ private constructor( * * The following fields are required: * ```java - * .adjustment() * .startDate() * ``` * @@ -4734,45 +9865,238 @@ 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().ifPresent { it.validate() } + adjustmentId() + endDate().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (startDate.asKnown().getOrNull()?.validity() ?: 0) + + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (adjustmentId.asKnown().isPresent) 1 else 0) + + (endDate.asKnown().getOrNull()?.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(): Optional = Optional.ofNullable(dateTime) + + fun billingCycleRelative(): Optional = + Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDateTime(dateTime: OffsetDateTime) = 1 + + override fun visitBillingCycleRelative( + billingCycleRelative: BillingCycleRelativeDate + ) = billingCycleRelative.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 { + + @JvmStatic fun ofDateTime(dateTime: OffsetDateTime) = StartDate(dateTime = dateTime) + + @JvmStatic + 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) - fun validate(): AddAdjustment = apply { - if (validated) { - return@apply + 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().ifPresent { it.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. - */ - @JvmSynthetic - internal fun validity(): Int = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (startDate.asKnown().getOrNull()?.validity() ?: 0) + - (endDate.asKnown().getOrNull()?.validity() ?: 0) + } /** The definition of a new adjustment to create and add to the subscription. */ @JsonDeserialize(using = Adjustment.Deserializer::class) @@ -4908,10 +10232,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 { @@ -5035,194 +10365,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(): Optional = Optional.ofNullable(dateTime) - - fun billingCycleRelative(): Optional = - Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitDateTime(dateTime: OffsetDateTime) = 1 - - override fun visitBillingCycleRelative( - billingCycleRelative: BillingCycleRelativeDate - ) = billingCycleRelative.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StartDate && dateTime == other.dateTime && billingCycleRelative == other.billingCycleRelative /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(dateTime, billingCycleRelative) /* spotless:on */ - - 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 { - - @JvmStatic fun ofDateTime(dateTime: OffsetDateTime) = StartDate(dateTime = dateTime) - - @JvmStatic - 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 @@ -5316,10 +10458,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 { @@ -5416,20 +10560,26 @@ 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 && + startDate == other.startDate && + adjustment == other.adjustment && + adjustmentId == other.adjustmentId && + 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(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 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val priceIntervalId: JsonField, private val billingCycleDay: JsonField, @@ -6039,10 +11189,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 { @@ -6135,6 +11287,7 @@ private constructor( } class FixedFeeQuantityTransition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val effectiveDate: JsonField, private val quantity: JsonField, @@ -6335,12 +11488,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 @@ -6439,10 +11595,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 { @@ -6539,12 +11697,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 @@ -6553,6 +11728,7 @@ private constructor( } class EditAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustmentIntervalId: JsonField, private val endDate: JsonField, @@ -6899,10 +12075,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 { @@ -7085,10 +12263,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 { @@ -7185,12 +12365,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 @@ -7203,10 +12387,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt index ded1d5e2..e248cd35 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt @@ -427,6 +427,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, @@ -786,13 +787,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() = @@ -924,7 +938,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() @@ -937,10 +951,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 64a19335..5ff83b37 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -38,7 +38,7 @@ import kotlin.jvm.optionals.getOrNull * This endpoint can be used to change an existing subscription's plan. It returns the serialized * updated subscription object. * - * The body parameter `change_option` determines when the plan change occurrs. Orb supports three + * 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 @@ -177,19 +177,16 @@ import kotlin.jvm.optionals.getOrNull * 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). @@ -1567,6 +1564,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>, @@ -3197,12 +3195,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 @@ -3335,7 +3388,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() @@ -3344,6 +3397,7 @@ private constructor( } class AddAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adjustment: JsonField, private val endDate: JsonField, @@ -3863,10 +3917,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 { @@ -3995,12 +4055,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 @@ -4009,6 +4074,7 @@ private constructor( } class AddPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, private val discounts: JsonField>, @@ -4129,7 +4195,7 @@ private constructor( fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("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). @@ -4465,7 +4531,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)) /** Alias for calling [Builder.price] with `price.orElse(null)`. */ @@ -4483,28 +4549,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.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)) + /** 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)`. */ @@ -4519,9 +4575,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 @@ -4530,10 +4593,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)`. */ @@ -4544,6 +4617,10 @@ private constructor( 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)`. @@ -4551,32 +4628,32 @@ private constructor( 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)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) /** * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + 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 @@ -4587,40 +4664,36 @@ private constructor( /** * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** Alias for calling [price] with `Price.ofMinimum(minimum)`. */ + fun price(minimum: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimum(minimum)) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** 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)) @@ -4745,31 +4818,38 @@ private constructor( (if (priceId.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - /** 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 tieredBps: NewSubscriptionTieredBpsPrice? = null, - private val bps: NewSubscriptionBpsPrice? = null, - private val bulkBps: NewSubscriptionBulkBpsPrice? = 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, @@ -4777,34 +4857,21 @@ 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 minimum: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { fun unit(): Optional = Optional.ofNullable(unit) - fun package_(): Optional = Optional.ofNullable(package_) - - fun matrix(): Optional = Optional.ofNullable(matrix) - fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = - Optional.ofNullable(tieredBps) - - fun bps(): Optional = Optional.ofNullable(bps) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun package_(): Optional = Optional.ofNullable(package_) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun matrix(): Optional = Optional.ofNullable(matrix) fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) @@ -4815,13 +4882,22 @@ private constructor( fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) fun packageWithAllocation(): Optional = Optional.ofNullable(packageWithAllocation) - fun tieredWithProration(): Optional = + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) fun unitWithProration(): Optional = @@ -4830,12 +4906,28 @@ private constructor( fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + fun groupedWithMeteredMinimum(): + Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) fun scalableMatrixWithUnitPricing(): Optional = @@ -4848,43 +4940,22 @@ private constructor( fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) - - fun groupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(groupedWithMeteredMinimum) - - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) - - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + fun minimum(): Optional = + Optional.ofNullable(minimum) - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) - - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + fun percent(): Optional = Optional.ofNullable(percent) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) fun isUnit(): Boolean = unit != null - fun isPackage(): Boolean = package_ != null - - fun isMatrix(): Boolean = matrix != null - fun isTiered(): Boolean = tiered != null - fun isTieredBps(): Boolean = tieredBps != null - - fun isBps(): Boolean = bps != null + fun isBulk(): Boolean = bulk != null - fun isBulkBps(): Boolean = bulkBps != null + fun isPackage(): Boolean = package_ != null - fun isBulk(): Boolean = bulk != null + fun isMatrix(): Boolean = matrix != null fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null @@ -4892,56 +4963,58 @@ private constructor( 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 isBulkWithProration(): Boolean = bulkWithProration != null + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMinimum(): Boolean = minimum != null - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + fun isPercent(): Boolean = percent != null - fun isGroupedTiered(): Boolean = groupedTiered != null + fun isEventOutput(): Boolean = eventOutput != 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 asTieredBps(): NewSubscriptionTieredBpsPrice = tieredBps.getOrThrow("tieredBps") - - fun asBps(): NewSubscriptionBpsPrice = bps.getOrThrow("bps") + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") - fun asBulkBps(): NewSubscriptionBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") @@ -4952,13 +5025,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 = @@ -4967,12 +5049,27 @@ private constructor( fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = groupedAllocation.getOrThrow("groupedAllocation") - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - 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") @@ -4984,53 +5081,50 @@ private constructor( 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 asMinimum(): NewSubscriptionMinimumCompositePrice = minimum.getOrThrow("minimum") - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + fun asPercent(): Percent = percent.getOrThrow("percent") - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") fun _json(): Optional = Optional.ofNullable(_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) - tieredBps != null -> visitor.visitTieredBps(tieredBps) - bps != null -> visitor.visitBps(bps) - bulkBps != null -> visitor.visitBulkBps(bulkBps) 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 -> @@ -5039,19 +5133,9 @@ 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) + minimum != null -> visitor.visitMinimum(minimum) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) else -> visitor.unknown(_json) } @@ -5068,32 +5152,20 @@ 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() } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) { - tieredBps.validate() - } - - override fun visitBps(bps: NewSubscriptionBpsPrice) { - bps.validate() + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() } - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) { - bulkBps.validate() + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() } override fun visitThresholdTotalAmount( @@ -5114,10 +5186,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( @@ -5126,8 +5204,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() } @@ -5144,6 +5234,12 @@ private constructor( groupedAllocation.validate() } + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + override fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice @@ -5151,30 +5247,28 @@ private constructor( groupedWithProratedMinimum.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice ) { - bulkWithProration.validate() + groupedWithMeteredMinimum.validate() } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ) { - scalableMatrixWithUnitPricing.validate() + groupedWithMinMaxThresholds.validate() } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ) { - scalableMatrixWithTieredPricing.validate() + matrixWithDisplayName.validate() } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice ) { - cumulativeGroupedBulk.validate() + groupedTieredPackage.validate() } override fun visitMaxGroupTieredPackage( @@ -5183,40 +5277,36 @@ private constructor( maxGroupTieredPackage.validate() } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice ) { - groupedWithMeteredMinimum.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice ) { - matrixWithDisplayName.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ) { - groupedTieredPackage.validate() + cumulativeGroupedBulk.validate() } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) { + minimum.validate() } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + override fun visitPercent(percent: Percent) { + percent.validate() } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() } } ) @@ -5243,24 +5333,16 @@ private constructor( 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 visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - tieredBps.validity() - - override fun visitBps(bps: NewSubscriptionBpsPrice) = bps.validity() + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = - bulkBps.validity() + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() override fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice @@ -5274,16 +5356,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( @@ -5294,14 +5388,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: @@ -5317,33 +5431,13 @@ 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 visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() - - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + override fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + minimum.validity() - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + override fun visitPercent(percent: Percent) = percent.validity() - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5354,53 +5448,115 @@ 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 */ + 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 = /* 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 */ + 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}" - 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}" + 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}" + 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") } @@ -5409,23 +5565,14 @@ private constructor( @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) - @JvmStatic - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - - @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) - @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) - @JvmStatic - fun ofTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - Price(tieredBps = tieredBps) - - @JvmStatic fun ofBps(bps: NewSubscriptionBpsPrice) = Price(bps = bps) + @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) @JvmStatic - fun ofBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = Price(bulkBps = bulkBps) + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) - @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) @JvmStatic fun ofThresholdTotalAmount( @@ -5441,8 +5588,13 @@ private constructor( Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic fun ofPackageWithAllocation( @@ -5450,9 +5602,17 @@ private constructor( ) = Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(tieredWithProration = tieredWithProration) + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) @JvmStatic fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = @@ -5462,30 +5622,34 @@ private constructor( fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = Price(groupedAllocation = groupedAllocation) + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + @JvmStatic fun ofGroupedWithProratedMinimum( groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) @JvmStatic fun ofMaxGroupTieredPackage( @@ -5493,33 +5657,29 @@ private constructor( ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) @JvmStatic - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) } /** @@ -5529,19 +5689,13 @@ private constructor( fun visitUnit(unit: NewSubscriptionUnitPrice): T - fun visitPackage(package_: NewSubscriptionPackagePrice): T - - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T - fun visitTiered(tiered: NewSubscriptionTieredPrice): T - fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice): T - - fun visitBps(bps: NewSubscriptionBpsPrice): T + fun visitBulk(bulk: NewSubscriptionBulkPrice): T - fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice): T + fun visitPackage(package_: NewSubscriptionPackagePrice): T - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T fun visitThresholdTotalAmount( thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice @@ -5553,16 +5707,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 @@ -5571,52 +5733,52 @@ private constructor( groupedAllocation: NewSubscriptionGroupedAllocationPrice ): T + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + fun visitGroupedWithProratedMinimum( groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice ): T - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice ): T - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice ): T - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice ): T fun visitMaxGroupTieredPackage( maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice ): T - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice ): T - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice ): T - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice ): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + fun visitMinimum(minimum: NewSubscriptionMinimumCompositePrice): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + fun visitPercent(percent: Percent): T - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun visitEventOutput(eventOutput: EventOutput): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -5645,20 +5807,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) - } "tiered" -> { return tryDeserialize( node, @@ -5666,27 +5814,23 @@ private constructor( ) ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } - "tiered_bps" -> { + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "package" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) - } - "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bps = it, _json = json) } ?: Price(_json = json) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) } - "bulk_bps" -> { + "matrix" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) } "threshold_total_amount" -> { return tryDeserialize( @@ -5712,12 +5856,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" -> { @@ -5728,11 +5880,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) } @@ -5752,6 +5917,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, @@ -5760,40 +5933,36 @@ private constructor( ?.let { Price(groupedWithProratedMinimum = it, _json = json) } ?: Price(_json = json) } - "bulk_with_proration" -> { + "grouped_with_metered_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(bulkWithProration = it, _json = json) } + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } - "scalable_matrix_with_unit_pricing" -> { + "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } ?: Price(_json = json) } - "scalable_matrix_with_tiered_pricing" -> { + "matrix_with_display_name" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } - "cumulative_grouped_bulk" -> { + "grouped_tiered_package" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?.let { Price(groupedTieredPackage = it, _json = json) } ?: Price(_json = json) } "max_group_tiered_package" -> { @@ -5804,53 +5973,50 @@ private constructor( ?.let { Price(maxGroupTieredPackage = it, _json = json) } ?: Price(_json = json) } - "grouped_with_metered_minimum" -> { + "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } ?: Price(_json = json) } - "matrix_with_display_name" -> { + "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } ?: Price(_json = json) } - "grouped_tiered_package" -> { + "cumulative_grouped_bulk" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedTieredPackage = it, _json = json) } + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } - "matrix_with_allocation" -> { + "minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(minimum = it, _json = json) } ?: Price(_json = json) } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) } } @@ -5867,3012 +6033,17031 @@ 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.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.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.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 equals(other: Any?): Boolean { - if (this === other) { - return true - } + 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(), + ) - 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 */ - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, discounts, endDate, externalPriceId, maximumAmount, minimumAmount, planPhaseOrder, price, priceId, startDate, additionalProperties) } - /* spotless:on */ + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun hashCode(): Int = hashCode + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - 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 name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * 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 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") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the 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(): Optional = + billableMetricId.getOptional("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(): Optional = + billedInAdvance.getOptional("billed_in_advance") - @JvmField 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(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - @JvmField 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(): Optional = + conversionRate.getOptional("conversion_rate") - @JvmField 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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - @JvmStatic 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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("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().orElseThrow { 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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value 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 [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 - return /* spotless:off */ other is BillingCycleAlignment && value == other.value /* spotless:on */ - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * 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: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic 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) + } - @JvmSynthetic - 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 + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** 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() + + @JvmSynthetic + 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() + } - /** - * 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 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - adjustmentId() - validated = true - } + /** + * Within each billing cycle, specifies the 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 isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - class RemovePrice - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + private var validated: Boolean = false - @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 validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - /** - * 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(): Optional = externalPriceId.getOptional("external_price_id") + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** - * 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(): Optional = priceId.getOptional("price_id") + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * 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 + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - 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, + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(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 toBuilder() = Builder().from(this) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - companion object { + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - @JvmStatic fun builder() = Builder() - } + private var validated: Boolean = false - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + known() + validated = true + } - @JvmSynthetic - 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + return other is Cadence && value == other.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 - } + override fun hashCode() = value.hashCode() - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + override fun toString() = value.toString() + } - /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ - fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * 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 } + @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) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(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 + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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() } + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * 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 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (priceId.asKnown().isPresent) 1 else 0) + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + tiers().forEach { it.validate() } + validated = true + } - return /* spotless:off */ other is RemovePrice && externalPriceId == other.externalPriceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, priceId, additionalProperties) } - /* spotless:on */ + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** 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) + } - 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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - class ReplaceAdjustment - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + private var validated: Boolean = false - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** - * 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") + tierLowerBound() + unitAmount() + validated = true + } - /** - * 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 isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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 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 val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, 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 + override fun hashCode(): Int = hashCode - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun toBuilder() = Builder().from(this) + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun hashCode(): Int = hashCode - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - 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`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** The definition of a new adjustment to create and add to the subscription. */ - 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 [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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 [Metadata]. */ + class Builder internal constructor() { - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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() - ) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * 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 putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** + * 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.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 validated: Boolean = false - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + 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. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + return other is Metadata && + additionalProperties == other.additionalProperties + } - private var validated: Boolean = false + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + override fun hashCode(): Int = hashCode - adjustment().validate() - replacesAdjustmentId() - validated = true - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - 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. - */ - @JvmSynthetic - internal fun validity(): Int = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + 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 + } - /** 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 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, + ) + } - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + override fun hashCode(): Int = hashCode - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + 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}" + } - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + 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, + ) { + + @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(), + ) - fun minimum(): Optional = Optional.ofNullable(minimum) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an 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 maximum(): Optional = Optional.ofNullable(maximum) + /** + * 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 isPercentageDiscount(): Boolean = percentageDiscount != 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 isUsageDiscount(): Boolean = usageDiscount != null + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 isAmountDiscount(): Boolean = amountDiscount != 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 isMinimum(): Boolean = minimum != 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(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun isMaximum(): Boolean = maximum != 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(): Optional = + billedInAdvance.getOptional("billed_in_advance") - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("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(): Optional = + conversionRate.getOptional("conversion_rate") - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun _json(): Optional = Optional.ofNullable(_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(): Optional = + externalPriceId.getOptional("external_price_id") - 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) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun validate(): Adjustment = 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(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.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(): Optional = metadata.getOptional("metadata") - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.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(): Optional = referenceId.getOptional("reference_id") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.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 visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * 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 - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = 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 - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * 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. - */ - @JvmSynthetic - 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 + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** 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() + + @JvmSynthetic + 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 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * 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 visitMaximum(maximum: NewMaximum) = maximum.validity() + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 unknown(json: JsonValue?) = 0 + /** + * If the Price represents a fixed cost, the price 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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 - } + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 /* spotless:off */ other is Adjustment && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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 hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * 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 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") - } + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) - companion object { + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitMinimum(minimum: NewMinimum): T + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 visitMaximum(maximum: NewMaximum): T + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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") - } - } + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_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") } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_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().orElseThrow { + OrbInvalidDataException("Value is not a String") } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } + + known() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - 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") + return other is Cadence && value == other.value } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** 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, + ) { - return /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ - } + @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) + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ + @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: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun hashCode(): Int = hashCode + /** 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() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } + /** 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 + } - 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, - ) { + /** 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 + } - @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 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 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 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 + } - /** - * 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(): Optional = - allocationPrice.getOptional("allocation_price") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * [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(): Optional> = discounts.getOptional("discounts") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * 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(): Optional = externalPriceId.getOptional("external_price_id") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * 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(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(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(): Optional = maximumAmount.getOptional("maximum_amount") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * [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(): Optional = minimumAmount.getOptional("minimum_amount") + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - /** - * 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(): Optional = price.getOptional("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(): Optional = priceId.getOptional("price_id") + fun validate(): GroupedWithMinMaxThresholdsConfig = 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 + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + 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]. - * - * 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 a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + 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 GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + 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( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + 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() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, 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 + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire 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 [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = 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 [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - companion object { + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - 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) + } - @JvmSynthetic - 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) + } - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + /** + * 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.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 - } + private var validated: Boolean = false - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** Alias for calling [Builder.discounts] with `discounts.orElse(null)`. */ - @Deprecated("deprecated") - fun discounts(discounts: Optional>) = - discounts(discounts.getOrNull()) + validated = 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() } - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * 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) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 } - } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. 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 toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** The new quantity of the price, if the price is a fixed price. */ - 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 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 + } - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + 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, + ) + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. 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 + + 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}" } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + 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(), + ) - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.getOrNull()) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an 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.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 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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( + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal 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 { + + @JvmField val UNCHANGED = of("unchanged") + + @JvmField val PLAN_CHANGE_DATE = of("plan_change_date") + + @JvmField val START_OF_MONTH = of("start_of_month") + + @JvmStatic 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().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): BillingCycleAlignment = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + + 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(): Optional = externalPriceId.getOptional("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(): Optional = priceId.getOptional("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]. */ + @JvmStatic 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() + + @JvmSynthetic + 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 [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. 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)) + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + + /** + * 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + 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(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic 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().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + 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(): Optional = + allocationPrice.getOptional("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(): Optional> = discounts.getOptional("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(): Optional = externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = maximumAmount.getOptional("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(): Optional = minimumAmount.getOptional("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(): Optional = price.getOptional("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(): Optional = priceId.getOptional("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: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.discounts] with `discounts.orElse(null)`. */ + @Deprecated("deprecated") + fun discounts(discounts: Optional>) = + discounts(discounts.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. 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)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * 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)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * 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.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)) + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + + /** + * 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: + * ```java + * .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().ifPresent { it.validate() } + discounts().ifPresent { it.forEach { it.validate() } } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + /** 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(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): + Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): + Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun minimum(): Optional = + Optional.ofNullable(minimum) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(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(): Optional = Optional.ofNullable(_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. + */ + @JvmSynthetic + 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 { + + @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + @JvmStatic + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofMinimum(minimum: NewSubscriptionMinimumCompositePrice) = + Price(minimum = minimum) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + 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().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + 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: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * 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)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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: + * ```java + * .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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.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. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic 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().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.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: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + 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 + @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, + ) { + + @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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("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(): Optional = + billingCycleConfiguration.getOptional("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(): Optional = + conversionRate.getOptional("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(): Optional = + conversionRateConfig.getOptional("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(): Optional = currency.getOptional("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(): Optional = + dimensionalPriceConfiguration.getOptional("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(): Optional = + externalPriceId.getOptional("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(): Optional = + fixedPriceQuantity.getOptional("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(): Optional = + invoiceGroupingKey.getOptional("invoice_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(): Optional = + invoicingCycleConfiguration.getOptional("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(): Optional = metadata.getOptional("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(): Optional = referenceId.getOptional("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: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * 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: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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) + ) - /** Alias for calling [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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.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 } + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(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) + ) - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = 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: NewSubscriptionTieredBpsPrice) = - 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: NewSubscriptionBpsPrice) = price(Price.ofBps(bps)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: NewSubscriptionBulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + 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().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + 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.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: NewSubscriptionTierWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> 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.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + private var validated: Boolean = false - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + known() + validated = true + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + return other is Cadence && value == other.value + } - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + override fun hashCode() = value.hashCode() - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + override fun toString() = value.toString() + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** 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, + ) { - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + @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) + } - /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ - fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + @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: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * 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 } + /** 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() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** 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 + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** 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 + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** 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 + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** 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 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: - * ```java - * .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 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(): ReplacePrice = apply { - if (validated) { - return@apply - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - discounts().ifPresent { it.forEach { it.validate() } } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price().ifPresent { it.validate() } - priceId() - 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) + - (if (priceId.asKnown().isPresent) 1 else 0) + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } - /** 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, - ) { + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } - fun unit(): Optional = Optional.ofNullable(unit) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun package_(): Optional = Optional.ofNullable(package_) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun matrix(): Optional = Optional.ofNullable(matrix) + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } - fun tiered(): Optional = Optional.ofNullable(tiered) + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } - fun tieredBps(): Optional = - Optional.ofNullable(tieredBps) + override fun hashCode(): Int = hashCode - fun bps(): Optional = Optional.ofNullable(bps) + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire 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 bulk(): Optional = Optional.ofNullable(bulk) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + fun toBuilder() = Builder().from(this) - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + companion object { - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + private var additionalProperties: MutableMap = + mutableMapOf() - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun groupedWithProratedMinimum(): - Optional = - Optional.ofNullable(groupedWithProratedMinimum) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + private var validated: Boolean = false - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun groupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + validated = true + } - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun isUnit(): Boolean = unit != null + override fun hashCode(): Int = hashCode - fun isPackage(): Boolean = package_ != null + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun isMatrix(): Boolean = matrix != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isTiered(): Boolean = tiered != null + 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 isTieredBps(): Boolean = tieredBps != null + 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 isBps(): Boolean = bps != null + override fun hashCode(): Int = hashCode - fun isBulkBps(): Boolean = bulkBps != 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 isBulk(): Boolean = bulk != null + 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(), + ) - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != 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 isTieredPackage(): Boolean = tieredPackage != 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 isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 isUnitWithPercent(): Boolean = unitWithPercent != 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 isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * 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") - fun isTieredWithProration(): Boolean = tieredWithProration != 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(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun isUnitWithProration(): Boolean = unitWithProration != 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(): Optional = + billedInAdvance.getOptional("billed_in_advance") - fun isGroupedAllocation(): Boolean = groupedAllocation != 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(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != 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(): Optional = + conversionRate.getOptional("conversion_rate") - fun isBulkWithProration(): Boolean = bulkWithProration != 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(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != 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(): Optional = currency.getOptional("currency") - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != 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(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != 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(): Optional = + externalPriceId.getOptional("external_price_id") - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != 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(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != 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(): Optional = + invoiceGroupingKey.getOptional("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(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != 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(): Optional = metadata.getOptional("metadata") - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != 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(): Optional = referenceId.getOptional("reference_id") - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != 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 isGroupedTiered(): Boolean = groupedTiered != 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 asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + /** + * Returns the raw JSON value 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 asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + /** + * 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 asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + /** + * Returns the raw JSON value of [billableMetricId]. + * + * 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 asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * 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 - fun asTieredBps(): NewSubscriptionTieredBpsPrice = tieredBps.getOrThrow("tieredBps") + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * 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 asBps(): NewSubscriptionBpsPrice = bps.getOrThrow("bps") + /** + * Returns the raw JSON value 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 asBulkBps(): NewSubscriptionBulkBpsPrice = bulkBps.getOrThrow("bulkBps") + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * 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 asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [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 - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Returns the raw JSON value of [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 asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + @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: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** 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() + + @JvmSynthetic + 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 asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** 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: + * ```java + * 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 + } - fun asTieredWithProration(): NewSubscriptionTierWithProrationPrice = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * The 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 [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * If the Price represents a fixed cost, the price 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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 asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Within each billing cycle, specifies the 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") + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + 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 asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun _json(): Optional = Optional.ofNullable(_json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - 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 + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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(), ) - 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) } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): Price = apply { - if (validated) { - return@apply - } + fun validate(): Percent = apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) { - tieredBps.validate() - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitBps(bps: NewSubscriptionBpsPrice) { - bps.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) { - bulkBps.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + private var validated: Boolean = false - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() + fun validate(): Cadence = apply { + if (validated) { + return@apply } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + known() + validated = true + } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) { - tieredWithProration.validate() - } + return other is Cadence && value == other.value + } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + override fun hashCode() = value.hashCode() - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + override fun toString() = value.toString() + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + @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) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + @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: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() + /** 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) } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply } + + percent() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + 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. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + override fun hashCode(): Int = hashCode - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - override fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - tieredBps.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 visitBps(bps: NewSubscriptionBpsPrice) = bps.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = - bulkBps.validity() + fun toBuilder() = Builder().from(this) - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + companion object { - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** A builder for [Metadata]. */ + class Builder internal constructor() { - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = tieredWithProration.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * 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 visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + private var validated: Boolean = false - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + validated = true + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + return other is Metadata && + additionalProperties == other.additionalProperties + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + override fun hashCode(): Int = hashCode - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.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 /* 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 */ + 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}" } - 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 */ + 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(), + ) - 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 cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - 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") - @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = 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") - @JvmStatic - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * 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 - @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - @JvmStatic - fun ofTieredBps(tieredBps: NewSubscriptionTieredBpsPrice) = - Price(tieredBps = tieredBps) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - @JvmStatic fun ofBps(bps: NewSubscriptionBpsPrice) = Price(bps = bps) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - @JvmStatic - fun ofBulkBps(bulkBps: NewSubscriptionBulkBpsPrice) = Price(bulkBps = bulkBps) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - @JvmStatic - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - @JvmStatic - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = 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(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - @JvmStatic - fun ofTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(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(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = 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(): Optional = metadata.getOptional("metadata") - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = 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(): Optional = referenceId.getOptional("reference_id") - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = 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 - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * 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 - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = 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 - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - @JvmStatic - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JvmStatic - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = 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 - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * 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 [invoiceGroupingKey]. + * + * 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 visitUnit(unit: NewSubscriptionUnitPrice): 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 - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** + * Returns the raw JSON value 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 visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** + * Returns the raw JSON value of [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 visitTiered(tiered: NewSubscriptionTieredPrice): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitTieredBps(tieredBps: NewSubscriptionTieredBpsPrice): T + @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: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun visitBps(bps: NewSubscriptionBpsPrice): T + /** 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() + + @JvmSynthetic + 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 visitBulkBps(bulkBps: NewSubscriptionBulkBpsPrice): T + /** 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 + } - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** 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: + * ```java + * 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)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. 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 visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): 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. + */ + 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?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. 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 visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + /** + * 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 [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. 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?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. 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 visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. 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: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * 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 [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. 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 visitTieredWithProration( - tieredWithProration: NewSubscriptionTierWithProrationPrice - ): T + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. 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)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. 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 visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + /** + * 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?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. 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 visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. 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 visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + /** + * Within each billing cycle, specifies the 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 visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. 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)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. 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)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. 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 visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + private var validated: Boolean = false - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - internal class Deserializer : BaseDeserializer(Price::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): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + 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 (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) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "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) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = 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().orElseThrow { + OrbInvalidDataException("Value is not a String") } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + known() + 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. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithProration = 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 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(): Optional = groupingKey.getOptional("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: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + + /** 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 } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * 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 } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = 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) } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = 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 [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .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 } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + unitRatingKey() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = 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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + + 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "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) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = 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 } - "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. + */ + @JvmSynthetic + internal 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 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}" } } @@ -8881,12 +23066,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 @@ -8899,10 +23105,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt index 540ef03a..ebf98d21 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SubscriptionTrialInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endDate: JsonField, private val additionalProperties: MutableMap, @@ -164,12 +165,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt index aed15fa6..1c60f1d4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt @@ -318,6 +318,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, @@ -526,12 +527,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 @@ -544,10 +548,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt index a244c329..33462fef 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt @@ -229,10 +229,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt index 5a18ebce..13ca8078 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt @@ -274,6 +274,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, @@ -415,12 +416,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 @@ -433,10 +434,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt index 2267916a..5d88ed16 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt @@ -228,10 +228,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt index 73546d52..1fbcead0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt @@ -439,6 +439,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, @@ -790,13 +791,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() = @@ -933,7 +947,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() @@ -946,10 +960,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt index 4ad99b3b..bdc44097 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt @@ -441,6 +441,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, @@ -811,13 +812,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() = @@ -918,12 +932,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 @@ -935,10 +947,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt index 7a0c8216..c3100868 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt @@ -343,6 +343,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, @@ -551,12 +552,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 @@ -649,10 +653,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 { @@ -859,7 +865,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() @@ -873,10 +879,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-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt index 216adaa5..10bb453e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt @@ -114,10 +114,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 { @@ -208,6 +210,7 @@ private constructor( } class UngroupedSubscriptionUsage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val additionalProperties: MutableMap, @@ -363,6 +366,7 @@ private constructor( (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val billableMetric: JsonField, private val usage: JsonField>, @@ -603,6 +607,7 @@ private constructor( (viewMode.asKnown().getOrNull()?.validity() ?: 0) class BillableMetric + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, @@ -785,12 +790,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 @@ -799,6 +805,7 @@ private constructor( } class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val quantity: JsonField, private val timeframeEnd: JsonField, @@ -1035,12 +1042,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 @@ -1171,7 +1182,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() @@ -1184,12 +1195,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 @@ -1202,12 +1217,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 @@ -1216,6 +1231,7 @@ private constructor( } class GroupedSubscriptionUsage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -1416,6 +1432,7 @@ private constructor( (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val billableMetric: JsonField, private val metricGroup: JsonField, @@ -1697,6 +1714,7 @@ private constructor( (viewMode.asKnown().getOrNull()?.validity() ?: 0) class BillableMetric + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, @@ -1879,12 +1897,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 @@ -1893,6 +1912,7 @@ private constructor( } class MetricGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val propertyKey: JsonField, private val propertyValue: JsonField, @@ -2089,12 +2109,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 @@ -2103,6 +2126,7 @@ private constructor( } class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val quantity: JsonField, private val timeframeEnd: JsonField, @@ -2339,12 +2363,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 @@ -2475,7 +2503,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() @@ -2488,12 +2516,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 @@ -2506,12 +2539,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-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt index 715ea132..6a322311 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class Subscriptions +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val paginationMetadata: JsonField, @@ -219,12 +220,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-java-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt index 344a68f3..3d43c8e6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class TaxAmount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val taxRateDescription: JsonField, @@ -254,12 +255,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-java-core/src/main/kotlin/com/withorb/api/models/Threshold.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Threshold.kt index b580731b..215c8fb6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Threshold.kt +++ b/orb-java-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, @@ -161,12 +162,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-java-core/src/main/kotlin/com/withorb/api/models/Tier.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Tier.kt index 5e023f58..c67409c2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Tier.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Tier.kt @@ -17,7 +17,9 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Configuration for a single tier */ class Tier +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val firstUnit: JsonField, private val unitAmount: JsonField, @@ -51,7 +53,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). @@ -145,7 +147,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)) /** @@ -244,12 +246,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-java-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt deleted file mode 100644 index b3bfadbb..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TierConfig.kt +++ /dev/null @@ -1,251 +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 -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -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(): Optional = lastUnit.getOptional("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: - * ```java - * .firstUnit() - * .lastUnit() - * .unitAmount() - * ``` - */ - @JvmStatic 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() - - @JvmSynthetic - 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?) - - /** Alias for calling [Builder.lastUnit] with `lastUnit.orElse(null)`. */ - fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.getOrNull()) - - /** - * 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: - * ```java - * .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. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (firstUnit.asKnown().isPresent) 1 else 0) + - (if (lastUnit.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TierConfig && firstUnit == other.firstUnit && lastUnit == other.lastUnit && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, lastUnit, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TierConfig{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt index b83eb09b..c9f3f0d4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class TierSubLineItem +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val grouping: JsonField, @@ -331,6 +332,252 @@ private constructor( (tierConfig.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + class TierConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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(): Optional = lastUnit.getOptional("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: + * ```java + * .firstUnit() + * .lastUnit() + * .unitAmount() + * ``` + */ + @JvmStatic 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() + + @JvmSynthetic + 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?) + + /** Alias for calling [Builder.lastUnit] with `lastUnit.orElse(null)`. */ + fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.getOrNull()) + + /** + * 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: + * ```java + * .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. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstUnit.asKnown().isPresent) 1 else 0) + + (if (lastUnit.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 { /** @@ -441,7 +688,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() @@ -454,12 +701,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-java-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt deleted file mode 100644 index d096c8a5..00000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfig.kt +++ /dev/null @@ -1,190 +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 -import kotlin.jvm.optionals.getOrNull - -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: - * ```java - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - 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: - * ```java - * .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. - */ - @JvmSynthetic - internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt index a105c36a..50e0eb79 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt @@ -18,7 +18,9 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Configuration for tiered pricing */ class TieredConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val additionalProperties: MutableMap, @@ -176,12 +178,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-java-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt index 11cc36a9..9a43ba19 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt @@ -18,6 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class TieredConversionRateConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val conversionRateType: JsonField, private val tieredConfig: JsonField, @@ -319,7 +320,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() @@ -332,12 +333,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-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt index c638578f..b65edaf1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt @@ -164,10 +164,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-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt index 08d21a9f..9d1a3dda 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt @@ -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, @@ -155,12 +156,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-java-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt index 4f5a48e0..0fe0b864 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class TopUpInvoiceSettings +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val autoCollection: JsonField, private val netTerms: JsonField, @@ -297,12 +298,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-java-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt index 540ccba1..4bba3b30 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TransformPriceFilter.kt @@ -20,6 +20,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class TransformPriceFilter +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val field: JsonField, private val operator: JsonField, @@ -380,7 +381,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() @@ -505,7 +506,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() @@ -518,12 +519,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-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt index 4acde64b..9d108528 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class TrialDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonField, private val appliesToPriceIds: JsonField>, @@ -543,7 +544,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() @@ -556,12 +557,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-java-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt index c24f93cc..05309199 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt @@ -15,7 +15,9 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +/** Configuration for unit pricing */ class UnitConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val unitAmount: JsonField, private val additionalProperties: MutableMap, @@ -158,12 +160,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-java-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt index 1a24f924..79c00daa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt @@ -18,6 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class UnitConversionRateConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val conversionRateType: JsonField, private val unitConfig: JsonField, @@ -318,7 +319,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() @@ -331,12 +332,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-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt index 9fb49a92..73b966cb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class UsageDiscount +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val discountType: JsonField, private val usageDiscount: JsonField, @@ -473,7 +474,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() @@ -486,12 +487,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-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt index 4c901e8d..da13f186 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt @@ -22,6 +22,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class UsageDiscountInterval +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val appliesToPriceIntervalIds: JsonField>, private val discountType: JsonField, @@ -526,7 +527,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() @@ -539,12 +540,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-java-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt index 273f7879..0132be6d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class VoidInitiatedLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -860,7 +861,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() @@ -980,7 +981,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() @@ -1082,12 +1083,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 @@ -1099,12 +1098,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-java-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt index a26d576b..d9778c26 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class VoidLedgerEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val amount: JsonField, @@ -817,7 +818,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() @@ -937,7 +938,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() @@ -1039,12 +1040,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 @@ -1056,12 +1055,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-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt index d9b821ac..3dbc378d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt @@ -94,8 +94,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-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt index 8081f0a9..63c12f68 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt @@ -30,12 +30,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. */ fun createPlanVersion( planId: String, params: BetaCreatePlanVersionParams, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt index b4cf9689..c81e266b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt @@ -49,11 +49,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 */ fun create(params: CustomerCreateParams): CompletableFuture = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt index ae24feff..ec49cfdc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt @@ -33,7 +33,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-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt index 974887b7..cbc65eb3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt @@ -49,8 +49,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, @@ -58,22 +58,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. */ @@ -107,8 +107,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 @@ -119,18 +119,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. */ @@ -226,7 +226,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, @@ -256,7 +255,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. * @@ -311,7 +309,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. @@ -326,7 +323,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. @@ -345,7 +341,11 @@ interface EventServiceAsync { * { * "debug": { * "duplicate": [], - * "ingested": ["B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim"] + * "ingested": [ + * "B7E83HDMfJPAunXW", + * "SJs5DQJ3TnwSqEZE", + * "8SivfDsNKwCeAXim" + * ] * }, * "validation_failed": [] * } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt index cbe1a1e5..d3c3cab9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt @@ -202,8 +202,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. */ fun markPaid(invoiceId: String, params: InvoiceMarkPaidParams): CompletableFuture = markPaid(invoiceId, params, RequestOptions.none()) @@ -261,8 +261,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-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt index e7d229b3..b755fb5c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt @@ -104,7 +104,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 @@ -112,7 +111,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-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt index 3856014f..eb0fa131 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt @@ -187,7 +187,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 @@ -232,7 +231,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. @@ -410,7 +408,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 @@ -582,7 +579,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 @@ -599,7 +595,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, @@ -611,7 +606,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. @@ -661,7 +655,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. * @@ -716,7 +709,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 @@ -735,7 +727,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`, @@ -833,7 +824,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 @@ -916,8 +906,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 @@ -1060,7 +1050,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 @@ -1068,12 +1057,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-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt index e1ae6689..e19fabea 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt @@ -27,12 +27,7 @@ interface ExternalPlanIdServiceAsync { */ fun withOptions(modifier: Consumer): 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. */ fun createPlanVersion( externalPlanId: String, params: BetaExternalPlanIdCreatePlanVersionParams, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt index c5aecb4b..45db99c9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt @@ -46,7 +46,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 @@ -59,18 +58,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 @@ -88,7 +85,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 @@ -98,7 +94,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 @@ -130,7 +125,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 @@ -190,7 +184,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 @@ -203,18 +196,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 @@ -232,7 +223,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 @@ -242,7 +232,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 @@ -274,7 +263,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-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt index fadef44d..bee83008 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt @@ -42,14 +42,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. @@ -61,14 +59,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 @@ -78,34 +76,29 @@ 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. * * 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 - * * 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. */ @@ -161,7 +154,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 @@ -185,7 +177,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 @@ -193,7 +184,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 @@ -211,7 +201,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 @@ -290,7 +279,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 @@ -314,7 +302,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 @@ -322,7 +309,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 @@ -340,7 +326,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 @@ -418,14 +403,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. @@ -437,14 +420,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 @@ -454,34 +437,29 @@ 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. * * 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 - * * 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-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt index 7a10f783..69859bc8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt @@ -57,7 +57,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-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt index efa6ba5b..848015d4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt @@ -75,7 +75,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-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt index d9c8d598..5dc8a9e3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt @@ -88,8 +88,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-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt index b25a5918..96e14846 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt @@ -30,12 +30,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): PlanVersion = createPlanVersion(planId, params, RequestOptions.none()) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt index d5886aae..957d0fb9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt @@ -49,11 +49,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(params: CustomerCreateParams): Customer = create(params, RequestOptions.none()) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt index f1b1838c..ca5a8976 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt @@ -33,7 +33,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-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt index 9d7aa5ee..fab9f037 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt @@ -49,8 +49,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, @@ -58,22 +58,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. */ @@ -106,8 +106,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 @@ -118,18 +118,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. */ @@ -222,7 +222,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, @@ -252,7 +251,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. * @@ -307,7 +305,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. @@ -322,7 +319,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. @@ -341,7 +337,11 @@ interface EventService { * { * "debug": { * "duplicate": [], - * "ingested": ["B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim"] + * "ingested": [ + * "B7E83HDMfJPAunXW", + * "SJs5DQJ3TnwSqEZE", + * "8SivfDsNKwCeAXim" + * ] * }, * "validation_failed": [] * } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt index b08fe22e..8bb7b67c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt @@ -185,8 +185,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, params: InvoiceMarkPaidParams): Invoice = markPaid(invoiceId, params, RequestOptions.none()) @@ -238,8 +238,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-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt index 8635f9ee..b5a9f6bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt @@ -100,7 +100,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 @@ -108,7 +107,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-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt index 6d6c33ec..fe9561cb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt @@ -187,7 +187,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 @@ -232,7 +231,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. @@ -406,7 +404,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 @@ -564,7 +561,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 @@ -581,7 +577,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, @@ -593,7 +588,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. @@ -643,7 +637,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. * @@ -698,7 +691,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 @@ -717,7 +709,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`, @@ -811,7 +802,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 @@ -890,8 +880,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 @@ -1034,7 +1024,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 @@ -1042,12 +1031,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-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt index ae3c09ea..e99aa76f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt @@ -27,12 +27,7 @@ interface ExternalPlanIdService { */ fun withOptions(modifier: Consumer): 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, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt index 52cdcf9a..bab452f9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt @@ -46,7 +46,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 @@ -59,18 +58,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 @@ -88,7 +85,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 @@ -98,7 +94,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 @@ -130,7 +125,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 @@ -187,7 +181,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 @@ -200,18 +193,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 @@ -229,7 +220,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 @@ -239,7 +229,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 @@ -271,7 +260,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-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt index d1cb5063..c72bb724 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt @@ -42,14 +42,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. @@ -61,14 +59,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 @@ -78,34 +76,29 @@ 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. * * 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 - * * 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. */ @@ -156,7 +149,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 @@ -180,7 +172,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 @@ -188,7 +179,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 @@ -206,7 +196,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 @@ -284,7 +273,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 @@ -308,7 +296,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 @@ -316,7 +303,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 @@ -334,7 +320,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 @@ -412,14 +397,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. @@ -431,14 +414,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 @@ -448,34 +431,29 @@ 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. * * 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 - * * 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-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt index 2e2bacbb..a40958b9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt @@ -57,7 +57,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-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt index 10036f09..0770d863 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt @@ -71,7 +71,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 diff --git a/orb-java-core/src/main/resources/META-INF/proguard/orb-java-core.pro b/orb-java-core/src/main/resources/META-INF/proguard/orb-java-core.pro new file mode 100644 index 00000000..ac5f62da --- /dev/null +++ b/orb-java-core/src/main/resources/META-INF/proguard/orb-java-core.pro @@ -0,0 +1,32 @@ +# Jackson uses reflection and depends heavily on runtime attributes. +-keepattributes Exceptions,InnerClasses,Signature,Deprecated,*Annotation* + +# 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 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.** { + (...); + @com.fasterxml.jackson.annotation.* *; +} \ No newline at end of file diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt index d29d49e4..4170f41f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt @@ -6,6 +6,8 @@ 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 import java.util.concurrent.CompletableFuture @@ -251,17 +253,97 @@ 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 fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + callCount++ + if (callCount == 1) { + val future = CompletableFuture() + future.completeExceptionally( + OrbRetryableException("Simulated retryable failure") + ) + return future + } + return httpClient.executeAsync(request, requestOptions) + } + + override fun close() = httpClient.close() + } + + val retryingClient = + RetryingHttpClient.builder() + .httpClient(failingHttpClient) + .maxRetries(2) + .sleeper( + object : Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + + override fun close() {} + } + ) + .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) // Use a no-op `Sleeper` to make the test fast. .sleeper( - object : RetryingHttpClient.Sleeper { + object : Sleeper { override fun sleep(duration: Duration) {} override fun sleepAsync(duration: Duration): CompletableFuture = CompletableFuture.completedFuture(null) + + override fun close() {} } ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index f62a16ed..d6819e95 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -27,7 +27,15 @@ internal class AggregatedCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -144,7 +152,15 @@ internal class AggregatedCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -265,7 +281,15 @@ internal class AggregatedCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt index 86f3f61b..34ac805a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt @@ -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-java-core/src/test/kotlin/com/withorb/api/models/BpsConfigTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BpsConfigTest.kt deleted file mode 100644 index 252d6366..00000000 --- a/orb-java-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()).contains("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-java-core/src/test/kotlin/com/withorb/api/models/BpsTierTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BpsTierTest.kt deleted file mode 100644 index 9f0c953f..00000000 --- a/orb-java-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()).contains("maximum_amount") - assertThat(bpsTier.perUnitMaximum()).contains("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-java-core/src/test/kotlin/com/withorb/api/models/BulkBpsConfigTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BulkBpsConfigTest.kt deleted file mode 100644 index 8ff08186..00000000 --- a/orb-java-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-java-core/src/test/kotlin/com/withorb/api/models/BulkBpsTierTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BulkBpsTierTest.kt deleted file mode 100644 index 0e82ea72..00000000 --- a/orb-java-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()).contains("maximum_amount") - assertThat(bulkBpsTier.perUnitMaximum()).contains("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-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index 05ee64f7..a1ac5082 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-java-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,7 +298,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -416,6 +436,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -445,7 +466,7 @@ internal class ChangedSubscriptionResourcesTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -465,12 +486,19 @@ 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" + ) .succeeded(true) .build() ) @@ -487,7 +515,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")) @@ -767,7 +795,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -897,6 +933,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -952,6 +989,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() ) @@ -1066,11 +1106,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) @@ -1089,7 +1129,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") @@ -1107,9 +1147,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()) @@ -1117,7 +1163,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( @@ -1152,11 +1203,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( @@ -1244,7 +1298,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1367,6 +1429,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1396,7 +1459,7 @@ internal class ChangedSubscriptionResourcesTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1416,12 +1479,19 @@ 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" + ) .succeeded(true) .build() ) @@ -1438,7 +1508,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")) @@ -1712,7 +1782,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1835,6 +1913,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1890,6 +1969,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() ) @@ -2009,11 +2091,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) @@ -2034,7 +2116,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") @@ -2052,10 +2134,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")) @@ -2064,7 +2150,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( @@ -2099,11 +2190,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( @@ -2193,7 +2287,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2323,6 +2425,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -2352,7 +2455,7 @@ internal class ChangedSubscriptionResourcesTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2372,12 +2475,19 @@ 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" + ) .succeeded(true) .build() ) @@ -2394,7 +2504,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")) @@ -2674,7 +2784,15 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2804,6 +2922,7 @@ internal class ChangedSubscriptionResourcesTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -2859,6 +2978,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-java-core/src/test/kotlin/com/withorb/api/models/ConversionRateConfigTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ConversionRateConfigTest.kt new file mode 100644 index 00000000..ed54a2ca --- /dev/null +++ b/orb-java-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()).contains(unit) + assertThat(conversionRateConfig.tiered()).isEmpty + } + + @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()).isEmpty + assertThat(conversionRateConfig.tiered()).contains(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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index 21dd041d..fcf91045 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -33,7 +33,15 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -175,7 +183,15 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -316,7 +332,15 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index d6bcaf78..8dd14fcd 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -33,7 +33,15 @@ internal class CustomerCostListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -175,7 +183,15 @@ internal class CustomerCostListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -316,7 +332,15 @@ internal class CustomerCostListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt index 29b8dac0..dc12e338 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt @@ -27,6 +27,7 @@ internal class CustomerCreateParamsTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -101,6 +102,7 @@ internal class CustomerCreateParamsTest { ) .addAdditionalEmail("dev@stainless.com") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -173,6 +175,7 @@ internal class CustomerCreateParamsTest { ) assertThat(body.additionalEmails().getOrNull()).containsExactly("dev@stainless.com") assertThat(body.autoCollection()).contains(true) + assertThat(body.autoIssuance()).contains(true) assertThat(body.billingAddress()) .contains( AddressInput.builder() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt index 23a9caaf..8fb52e17 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 3e39c0bf..aa76a7ed 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -232,7 +232,15 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -362,6 +370,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -417,6 +426,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() ) @@ -686,7 +698,17 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -829,6 +851,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -884,6 +907,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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt index 615cba89..746f8a2e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index ae60ab6b..6dd99341 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -232,7 +232,15 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -362,6 +370,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -417,6 +426,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() ) @@ -685,7 +697,17 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -828,6 +850,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -883,6 +906,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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 79e0ce7e..98d0f59b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -248,7 +248,17 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -401,6 +411,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -458,6 +469,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -727,7 +741,17 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -880,6 +904,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -937,6 +962,9 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1209,7 +1237,17 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1362,6 +1400,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1419,6 +1458,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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index 9db46fd7..4a120a7c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -232,7 +232,15 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -362,6 +370,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -417,6 +426,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() ) @@ -685,7 +697,17 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -828,6 +850,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -883,6 +906,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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index 3c66b293..ed59e99e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -248,7 +248,17 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -401,6 +411,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -458,6 +469,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -727,7 +741,17 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -880,6 +904,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -937,6 +962,9 @@ internal class CustomerCreditLedgerListPageResponseTest { Invoice.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1209,7 +1237,17 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1362,6 +1400,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1419,6 +1458,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-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index 3c2c8944..234881c4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -232,7 +232,15 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -362,6 +370,7 @@ internal class CustomerCreditLedgerListResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -417,6 +426,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() ) @@ -685,7 +697,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -828,6 +850,7 @@ internal class CustomerCreditLedgerListResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -883,6 +906,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-java-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt index bb3c672c..3d264a89 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt index 1d073710..66e0bf5b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt @@ -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()).contains(true) assertThat(customer.balance()).isEqualTo("balance") assertThat(customer.billingAddress()) .contains( @@ -193,6 +195,7 @@ internal class CustomerTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt index 35e5ff03..801e5aee 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt @@ -26,6 +26,7 @@ internal class CustomerUpdateByExternalIdParamsTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -109,6 +110,7 @@ internal class CustomerUpdateByExternalIdParamsTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -180,6 +182,7 @@ internal class CustomerUpdateByExternalIdParamsTest { ) assertThat(body.additionalEmails().getOrNull()).containsExactly("string") assertThat(body.autoCollection()).contains(true) + assertThat(body.autoIssuance()).contains(true) assertThat(body.billingAddress()) .contains( AddressInput.builder() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt index 47d6814d..d64ef322 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt @@ -26,6 +26,7 @@ internal class CustomerUpdateParamsTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -109,6 +110,7 @@ internal class CustomerUpdateParamsTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -180,6 +182,7 @@ internal class CustomerUpdateParamsTest { ) assertThat(body.additionalEmails().getOrNull()).containsExactly("string") assertThat(body.autoCollection()).contains(true) + assertThat(body.autoIssuance()).contains(true) assertThat(body.billingAddress()) .contains( AddressInput.builder() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index c1a3b297..0056aafa 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -229,7 +229,15 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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 +367,7 @@ internal class IncrementLedgerEntryTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -414,6 +423,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,7 +667,15 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -778,6 +798,7 @@ internal class IncrementLedgerEntryTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -833,6 +854,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,7 +1102,15 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1208,6 +1240,7 @@ internal class IncrementLedgerEntryTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1263,6 +1296,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-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt index 53c5cf8c..dfcb7b59 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt +++ b/orb-java-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()) + .contains(InvoiceCreateParams.DueDate.ofDate(LocalDate.parse("2023-09-22"))) assertThat(body.externalCustomerId()).contains("external-customer-id") assertThat(body.memo()).contains("An optional memo for my invoice.") assertThat(body.metadata()) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 58e832ad..67ca2c57 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -191,7 +191,15 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -302,6 +310,7 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -359,6 +368,9 @@ internal class InvoiceFetchUpcomingResponseTest { InvoiceFetchUpcomingResponse.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -577,7 +589,15 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -683,6 +703,7 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -745,6 +766,9 @@ internal class InvoiceFetchUpcomingResponseTest { InvoiceFetchUpcomingResponse.PaymentAttempt.PaymentProvider.STRIPE ) .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -961,7 +985,15 @@ internal class InvoiceFetchUpcomingResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1072,6 +1104,7 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1129,6 +1162,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-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index fe32e14d..9f9283ad 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -100,7 +100,15 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -202,6 +210,7 @@ internal class InvoiceLineItemCreateResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -310,7 +319,15 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -416,6 +433,7 @@ internal class InvoiceLineItemCreateResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) ) @@ -521,7 +539,15 @@ internal class InvoiceLineItemCreateResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -623,6 +649,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-java-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index 56d7eff0..e4d0df0a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -200,7 +200,15 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -330,6 +338,7 @@ internal class InvoiceListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -385,6 +394,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() ) @@ -595,7 +607,15 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -718,6 +738,7 @@ internal class InvoiceListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -773,6 +794,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() ) @@ -992,7 +1016,15 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1122,6 +1154,7 @@ internal class InvoiceListPageResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1177,6 +1210,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-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index c6855dbf..085ede1f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -187,7 +187,15 @@ internal class InvoiceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -298,6 +306,7 @@ internal class InvoiceTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -353,6 +362,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() ) @@ -564,7 +576,15 @@ internal class InvoiceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -670,6 +690,7 @@ internal class InvoiceTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -729,6 +750,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() ) @@ -937,7 +961,15 @@ internal class InvoiceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1048,6 +1080,7 @@ internal class InvoiceTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1103,6 +1136,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-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt index 2392b240..4e87946b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt +++ b/orb-java-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()) + .contains(InvoiceUpdateParams.DueDate.ofDate(LocalDate.parse("2023-09-22"))) assertThat(body.metadata()) .contains( InvoiceUpdateParams.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + assertThat(body.netTerms()).contains(0L) } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemListPageResponseTest.kt index 9304e36b..38156b7d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemListPageResponseTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt index 7d2118f2..4d157663 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt @@ -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()).contains(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-java-core/src/test/kotlin/com/withorb/api/models/MatrixSubLineItemTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixSubLineItemTest.kt index efe0eef3..e3a9ae49 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixSubLineItemTest.kt +++ b/orb-java-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()).contains(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-java-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigTest.kt index 8f337469..7afd7e9d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt index f2eaba15..4f47b173 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 0954a8dc..9e0718b8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-java-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() @@ -358,7 +359,15 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -496,7 +505,15 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -700,11 +717,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") @@ -727,7 +745,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") @@ -745,10 +763,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") @@ -762,7 +784,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( @@ -797,11 +824,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( @@ -902,7 +933,17 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1055,6 +1096,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1084,7 +1126,7 @@ internal class MutatedSubscriptionTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1104,14 +1146,21 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1128,7 +1177,7 @@ internal class MutatedSubscriptionTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status(ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED) .subscription( SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build() ) @@ -1433,7 +1482,17 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1586,6 +1645,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1643,6 +1703,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 +1785,7 @@ internal class MutatedSubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -2030,7 +2094,15 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2163,7 +2235,15 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2366,11 +2446,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) @@ -2391,7 +2471,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") @@ -2409,10 +2489,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")) @@ -2421,7 +2506,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( @@ -2456,11 +2546,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( @@ -2560,7 +2654,17 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2703,6 +2807,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -2732,7 +2837,7 @@ internal class MutatedSubscriptionTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2752,12 +2857,19 @@ 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" + ) .succeeded(true) .build() ) @@ -2774,7 +2886,7 @@ internal class MutatedSubscriptionTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status(ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED) .subscription( SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build() ) @@ -3068,7 +3180,17 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -3211,6 +3333,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3266,6 +3389,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 +3472,7 @@ internal class MutatedSubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -3645,7 +3772,15 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -3783,7 +3918,15 @@ internal class MutatedSubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -3987,11 +4130,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") @@ -4014,7 +4158,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") @@ -4032,10 +4176,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") @@ -4049,7 +4197,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( @@ -4084,11 +4237,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( @@ -4189,7 +4346,17 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -4342,6 +4509,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -4371,7 +4539,7 @@ internal class MutatedSubscriptionTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4391,14 +4559,21 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -4415,7 +4590,7 @@ internal class MutatedSubscriptionTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status(ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED) .subscription( SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build() ) @@ -4720,7 +4895,17 @@ internal class MutatedSubscriptionTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -4873,6 +5058,7 @@ internal class MutatedSubscriptionTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -4930,6 +5116,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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBpsPriceTest.kt deleted file mode 100644 index 31cbe842..00000000 --- a/orb-java-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()).contains("billable_metric_id") - assertThat(newFloatingBpsPrice.billedInAdvance()).contains(true) - assertThat(newFloatingBpsPrice.billingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingBpsPrice.conversionRate()).contains(0.0) - assertThat(newFloatingBpsPrice.conversionRateConfig()) - .contains( - NewFloatingBpsPrice.ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newFloatingBpsPrice.dimensionalPriceConfiguration()) - .contains( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newFloatingBpsPrice.externalPriceId()).contains("external_price_id") - assertThat(newFloatingBpsPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newFloatingBpsPrice.invoiceGroupingKey()).contains("x") - assertThat(newFloatingBpsPrice.invoicingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingBpsPrice.metadata()) - .contains( - 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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt index 389d92e8..45faf371 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt @@ -84,7 +84,7 @@ internal class NewFloatingBulkPriceTest { assertThat(newFloatingBulkPrice.conversionRate()).contains(0.0) assertThat(newFloatingBulkPrice.conversionRateConfig()) .contains( - NewFloatingBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt index fb89dc81..340da829 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +107,7 @@ internal class NewFloatingBulkWithProrationPriceTest { assertThat(newFloatingBulkWithProrationPrice.conversionRate()).contains(0.0) assertThat(newFloatingBulkWithProrationPrice.conversionRateConfig()) .contains( - NewFloatingBulkWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt index 0e2be43a..8952c2ab 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt +++ b/orb-java-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") @@ -85,7 +103,7 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { assertThat(newFloatingCumulativeGroupedBulkPrice.conversionRate()).contains(0.0) assertThat(newFloatingCumulativeGroupedBulkPrice.conversionRateConfig()) .contains( - NewFloatingCumulativeGroupedBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt index 957e7746..094d0a60 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt +++ b/orb-java-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") @@ -85,7 +89,7 @@ internal class NewFloatingGroupedAllocationPriceTest { assertThat(newFloatingGroupedAllocationPrice.conversionRate()).contains(0.0) assertThat(newFloatingGroupedAllocationPrice.conversionRateConfig()) .contains( - NewFloatingGroupedAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt index ee35a858..66160bb0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt +++ b/orb-java-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") @@ -85,7 +115,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { assertThat(newFloatingGroupedTieredPackagePrice.conversionRate()).contains(0.0) assertThat(newFloatingGroupedTieredPackagePrice.conversionRateConfig()) .contains( - NewFloatingGroupedTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt index 31ada781..8676809f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt +++ b/orb-java-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") @@ -84,7 +108,7 @@ internal class NewFloatingGroupedTieredPriceTest { assertThat(newFloatingGroupedTieredPrice.conversionRate()).contains(0.0) assertThat(newFloatingGroupedTieredPrice.conversionRateConfig()) .contains( - NewFloatingGroupedTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt index b1480d22..c72fd666 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-java-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") @@ -90,7 +130,7 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { assertThat(newFloatingGroupedWithMeteredMinimumPrice.conversionRate()).contains(0.0) assertThat(newFloatingGroupedWithMeteredMinimumPrice.conversionRateConfig()) .contains( - NewFloatingGroupedWithMeteredMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt index cb98e394..5c5a996c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt +++ b/orb-java-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") @@ -92,7 +96,7 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { assertThat(newFloatingGroupedWithProratedMinimumPrice.conversionRate()).contains(0.0) assertThat(newFloatingGroupedWithProratedMinimumPrice.conversionRateConfig()) .contains( - NewFloatingGroupedWithProratedMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt index c24bb204..3f1972cf 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt @@ -98,7 +98,7 @@ internal class NewFloatingMatrixPriceTest { assertThat(newFloatingMatrixPrice.conversionRate()).contains(0.0) assertThat(newFloatingMatrixPrice.conversionRateConfig()) .contains( - NewFloatingMatrixPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt index 8dca9161..0755eeb7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt +++ b/orb-java-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() @@ -101,7 +101,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { assertThat(newFloatingMatrixWithAllocationPrice.conversionRate()).contains(0.0) assertThat(newFloatingMatrixWithAllocationPrice.conversionRateConfig()) .contains( - NewFloatingMatrixWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt index 31abf4af..a611895a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt +++ b/orb-java-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()) @@ -85,7 +102,7 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { assertThat(newFloatingMatrixWithDisplayNamePrice.conversionRate()).contains(0.0) assertThat(newFloatingMatrixWithDisplayNamePrice.conversionRateConfig()) .contains( - NewFloatingMatrixWithDisplayNamePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt index d4bd794f..45b67882 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt +++ b/orb-java-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()) @@ -85,7 +115,7 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { assertThat(newFloatingMaxGroupTieredPackagePrice.conversionRate()).contains(0.0) assertThat(newFloatingMaxGroupTieredPackagePrice.conversionRateConfig()) .contains( - NewFloatingMaxGroupTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt similarity index 60% rename from orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt rename to orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt index 73944842..476e03ce 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkBpsPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt @@ -8,27 +8,22 @@ import com.withorb.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class NewFloatingBulkBpsPriceTest { +internal class NewFloatingMinimumCompositePriceTest { @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) + val newFloatingMinimumCompositePrice = + NewFloatingMinimumCompositePrice.builder() + .cadence(NewFloatingMinimumCompositePrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(NewFloatingBulkBpsPrice.ModelType.BULK_BPS) + .minimumConfig( + NewFloatingMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .modelType(NewFloatingMinimumCompositePrice.ModelType.MINIMUM) .name("Annual fee") .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -59,44 +54,40 @@ internal class NewFloatingBulkBpsPriceTest { .build() ) .metadata( - NewFloatingBulkBpsPrice.Metadata.builder() + NewFloatingMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .build() - assertThat(newFloatingBulkBpsPrice.bulkBpsConfig()) + assertThat(newFloatingMinimumCompositePrice.cadence()) + .isEqualTo(NewFloatingMinimumCompositePrice.Cadence.ANNUAL) + assertThat(newFloatingMinimumCompositePrice.currency()).isEqualTo("currency") + assertThat(newFloatingMinimumCompositePrice.itemId()).isEqualTo("item_id") + assertThat(newFloatingMinimumCompositePrice.minimumConfig()) .isEqualTo( - BulkBpsConfig.builder() - .addTier( - BulkBpsTier.builder() - .bps(0.0) - .maximumAmount("maximum_amount") - .perUnitMaximum("per_unit_maximum") - .build() - ) + NewFloatingMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) .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()).contains("billable_metric_id") - assertThat(newFloatingBulkBpsPrice.billedInAdvance()).contains(true) - assertThat(newFloatingBulkBpsPrice.billingCycleConfiguration()) + assertThat(newFloatingMinimumCompositePrice.modelType()) + .isEqualTo(NewFloatingMinimumCompositePrice.ModelType.MINIMUM) + assertThat(newFloatingMinimumCompositePrice.name()).isEqualTo("Annual fee") + assertThat(newFloatingMinimumCompositePrice.billableMetricId()) + .contains("billable_metric_id") + assertThat(newFloatingMinimumCompositePrice.billedInAdvance()).contains(true) + assertThat(newFloatingMinimumCompositePrice.billingCycleConfiguration()) .contains( NewBillingCycleConfiguration.builder() .duration(0L) .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) - assertThat(newFloatingBulkBpsPrice.conversionRate()).contains(0.0) - assertThat(newFloatingBulkBpsPrice.conversionRateConfig()) + assertThat(newFloatingMinimumCompositePrice.conversionRate()).contains(0.0) + assertThat(newFloatingMinimumCompositePrice.conversionRateConfig()) .contains( - NewFloatingBulkBpsPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -105,7 +96,7 @@ internal class NewFloatingBulkBpsPriceTest { .build() ) ) - assertThat(newFloatingBulkBpsPrice.dimensionalPriceConfiguration()) + assertThat(newFloatingMinimumCompositePrice.dimensionalPriceConfiguration()) .contains( NewDimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -113,19 +104,19 @@ internal class NewFloatingBulkBpsPriceTest { .externalDimensionalPriceGroupId("external_dimensional_price_group_id") .build() ) - assertThat(newFloatingBulkBpsPrice.externalPriceId()).contains("external_price_id") - assertThat(newFloatingBulkBpsPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newFloatingBulkBpsPrice.invoiceGroupingKey()).contains("x") - assertThat(newFloatingBulkBpsPrice.invoicingCycleConfiguration()) + assertThat(newFloatingMinimumCompositePrice.externalPriceId()).contains("external_price_id") + assertThat(newFloatingMinimumCompositePrice.fixedPriceQuantity()).contains(0.0) + assertThat(newFloatingMinimumCompositePrice.invoiceGroupingKey()).contains("x") + assertThat(newFloatingMinimumCompositePrice.invoicingCycleConfiguration()) .contains( NewBillingCycleConfiguration.builder() .duration(0L) .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) - assertThat(newFloatingBulkBpsPrice.metadata()) + assertThat(newFloatingMinimumCompositePrice.metadata()) .contains( - NewFloatingBulkBpsPrice.Metadata.builder() + NewFloatingMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -134,23 +125,18 @@ internal class NewFloatingBulkBpsPriceTest { @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) + val newFloatingMinimumCompositePrice = + NewFloatingMinimumCompositePrice.builder() + .cadence(NewFloatingMinimumCompositePrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(NewFloatingBulkBpsPrice.ModelType.BULK_BPS) + .minimumConfig( + NewFloatingMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) + .modelType(NewFloatingMinimumCompositePrice.ModelType.MINIMUM) .name("Annual fee") .billableMetricId("billable_metric_id") .billedInAdvance(true) @@ -181,18 +167,19 @@ internal class NewFloatingBulkBpsPriceTest { .build() ) .metadata( - NewFloatingBulkBpsPrice.Metadata.builder() + NewFloatingMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .build() - val roundtrippedNewFloatingBulkBpsPrice = + val roundtrippedNewFloatingMinimumCompositePrice = jsonMapper.readValue( - jsonMapper.writeValueAsString(newFloatingBulkBpsPrice), - jacksonTypeRef(), + jsonMapper.writeValueAsString(newFloatingMinimumCompositePrice), + jacksonTypeRef(), ) - assertThat(roundtrippedNewFloatingBulkBpsPrice).isEqualTo(newFloatingBulkBpsPrice) + assertThat(roundtrippedNewFloatingMinimumCompositePrice) + .isEqualTo(newFloatingMinimumCompositePrice) } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt index 6cc7e55f..ed37b52e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt +++ b/orb-java-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()).contains("billable_metric_id") assertThat(newFloatingPackagePrice.billedInAdvance()).contains(true) @@ -80,7 +80,7 @@ internal class NewFloatingPackagePriceTest { assertThat(newFloatingPackagePrice.conversionRate()).contains(0.0) assertThat(newFloatingPackagePrice.conversionRateConfig()) .contains( - NewFloatingPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt index e8e18961..ead45276 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +89,7 @@ internal class NewFloatingPackageWithAllocationPriceTest { assertThat(newFloatingPackageWithAllocationPrice.conversionRate()).contains(0.0) assertThat(newFloatingPackageWithAllocationPrice.conversionRateConfig()) .contains( - NewFloatingPackageWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt index 0d43b4a4..ff18721f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-java-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()) @@ -98,7 +156,7 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { assertThat(newFloatingScalableMatrixWithTieredPricingPrice.conversionRate()).contains(0.0) assertThat(newFloatingScalableMatrixWithTieredPricingPrice.conversionRateConfig()) .contains( - NewFloatingScalableMatrixWithTieredPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -153,7 +211,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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt index 1d65a6c2..202827aa 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-java-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()) @@ -96,7 +122,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { assertThat(newFloatingScalableMatrixWithUnitPricingPrice.conversionRate()).contains(0.0) assertThat(newFloatingScalableMatrixWithUnitPricingPrice.conversionRateConfig()) .contains( - NewFloatingScalableMatrixWithUnitPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -149,7 +175,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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt index ea55d231..84811441 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +117,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { assertThat(newFloatingThresholdTotalAmountPrice.conversionRate()).contains(0.0) assertThat(newFloatingThresholdTotalAmountPrice.conversionRateConfig()) .contains( - NewFloatingThresholdTotalAmountPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredBpsPriceTest.kt deleted file mode 100644 index f34f3f41..00000000 --- a/orb-java-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()).contains("billable_metric_id") - assertThat(newFloatingTieredBpsPrice.billedInAdvance()).contains(true) - assertThat(newFloatingTieredBpsPrice.billingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingTieredBpsPrice.conversionRate()).contains(0.0) - assertThat(newFloatingTieredBpsPrice.conversionRateConfig()) - .contains( - NewFloatingTieredBpsPrice.ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newFloatingTieredBpsPrice.dimensionalPriceConfiguration()) - .contains( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newFloatingTieredBpsPrice.externalPriceId()).contains("external_price_id") - assertThat(newFloatingTieredBpsPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newFloatingTieredBpsPrice.invoiceGroupingKey()).contains("x") - assertThat(newFloatingTieredBpsPrice.invoicingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newFloatingTieredBpsPrice.metadata()) - .contains( - 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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt index 51edcac8..9c48a9c9 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt +++ b/orb-java-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()).contains("billable_metric_id") @@ -84,7 +108,7 @@ internal class NewFloatingTieredPackagePriceTest { assertThat(newFloatingTieredPackagePrice.conversionRate()).contains(0.0) assertThat(newFloatingTieredPackagePrice.conversionRateConfig()) .contains( - NewFloatingTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt index bbeff36d..35b3511b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt +++ b/orb-java-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()) @@ -90,7 +124,7 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { assertThat(newFloatingTieredPackageWithMinimumPrice.conversionRate()).contains(0.0) assertThat(newFloatingTieredPackageWithMinimumPrice.conversionRateConfig()) .contains( - NewFloatingTieredPackageWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt index b006ee48..731bd033 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt @@ -96,7 +96,7 @@ internal class NewFloatingTieredPriceTest { assertThat(newFloatingTieredPrice.conversionRate()).contains(0.0) assertThat(newFloatingTieredPrice.conversionRateConfig()) .contains( - NewFloatingTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt index 375df300..bd4fdacc 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +115,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { assertThat(newFloatingTieredWithMinimumPrice.conversionRate()).contains(0.0) assertThat(newFloatingTieredWithMinimumPrice.conversionRateConfig()) .contains( - NewFloatingTieredWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt index a226d5fc..1769baf1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +96,7 @@ internal class NewFloatingTieredWithProrationPriceTest { assertThat(newFloatingTieredWithProrationPrice.conversionRate()).contains(0.0) assertThat(newFloatingTieredWithProrationPrice.conversionRateConfig()) .contains( - NewFloatingTieredWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt index 4237fd57..70ad31ec 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt @@ -74,7 +74,7 @@ internal class NewFloatingUnitPriceTest { assertThat(newFloatingUnitPrice.conversionRate()).contains(0.0) assertThat(newFloatingUnitPrice.conversionRateConfig()) .contains( - NewFloatingUnitPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt index 86d00648..081e0064 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +87,7 @@ internal class NewFloatingUnitWithPercentPriceTest { assertThat(newFloatingUnitWithPercentPrice.conversionRate()).contains(0.0) assertThat(newFloatingUnitWithPercentPrice.conversionRateConfig()) .contains( - NewFloatingUnitWithPercentPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt index ae61ae4e..2e4fae2c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +85,7 @@ internal class NewFloatingUnitWithProrationPriceTest { assertThat(newFloatingUnitWithProrationPrice.conversionRate()).contains(0.0) assertThat(newFloatingUnitWithProrationPrice.conversionRateConfig()) .contains( - NewFloatingUnitWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBpsPriceTest.kt deleted file mode 100644 index 011577ed..00000000 --- a/orb-java-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()).contains("billable_metric_id") - assertThat(newPlanBpsPrice.billedInAdvance()).contains(true) - assertThat(newPlanBpsPrice.billingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanBpsPrice.conversionRate()).contains(0.0) - assertThat(newPlanBpsPrice.conversionRateConfig()) - .contains( - NewPlanBpsPrice.ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newPlanBpsPrice.currency()).contains("currency") - assertThat(newPlanBpsPrice.dimensionalPriceConfiguration()) - .contains( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newPlanBpsPrice.externalPriceId()).contains("external_price_id") - assertThat(newPlanBpsPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newPlanBpsPrice.invoiceGroupingKey()).contains("x") - assertThat(newPlanBpsPrice.invoicingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanBpsPrice.metadata()) - .contains( - NewPlanBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newPlanBpsPrice.referenceId()).contains("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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkBpsPriceTest.kt deleted file mode 100644 index 8b0c1e0c..00000000 --- a/orb-java-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()).contains("billable_metric_id") - assertThat(newPlanBulkBpsPrice.billedInAdvance()).contains(true) - assertThat(newPlanBulkBpsPrice.billingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanBulkBpsPrice.conversionRate()).contains(0.0) - assertThat(newPlanBulkBpsPrice.conversionRateConfig()) - .contains( - NewPlanBulkBpsPrice.ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newPlanBulkBpsPrice.currency()).contains("currency") - assertThat(newPlanBulkBpsPrice.dimensionalPriceConfiguration()) - .contains( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newPlanBulkBpsPrice.externalPriceId()).contains("external_price_id") - assertThat(newPlanBulkBpsPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newPlanBulkBpsPrice.invoiceGroupingKey()).contains("x") - assertThat(newPlanBulkBpsPrice.invoicingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanBulkBpsPrice.metadata()) - .contains( - NewPlanBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newPlanBulkBpsPrice.referenceId()).contains("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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt index c30ab03f..f3f1100a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt @@ -84,7 +84,7 @@ internal class NewPlanBulkPriceTest { assertThat(newPlanBulkPrice.conversionRate()).contains(0.0) assertThat(newPlanBulkPrice.conversionRateConfig()) .contains( - NewPlanBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt index 26145069..93f84aaf 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt +++ b/orb-java-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()) @@ -84,7 +106,7 @@ internal class NewPlanBulkWithProrationPriceTest { assertThat(newPlanBulkWithProrationPrice.conversionRate()).contains(0.0) assertThat(newPlanBulkWithProrationPrice.conversionRateConfig()) .contains( - NewPlanBulkWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt index 5cbd254f..20bd1b58 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt +++ b/orb-java-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") @@ -85,7 +102,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { assertThat(newPlanCumulativeGroupedBulkPrice.conversionRate()).contains(0.0) assertThat(newPlanCumulativeGroupedBulkPrice.conversionRateConfig()) .contains( - NewPlanCumulativeGroupedBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt index eca31922..5ce0cab0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt +++ b/orb-java-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") @@ -84,7 +88,7 @@ internal class NewPlanGroupedAllocationPriceTest { assertThat(newPlanGroupedAllocationPrice.conversionRate()).contains(0.0) assertThat(newPlanGroupedAllocationPrice.conversionRateConfig()) .contains( - NewPlanGroupedAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt index 7f9a77d9..a20e9666 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt +++ b/orb-java-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") @@ -85,7 +113,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { assertThat(newPlanGroupedTieredPackagePrice.conversionRate()).contains(0.0) assertThat(newPlanGroupedTieredPackagePrice.conversionRateConfig()) .contains( - NewPlanGroupedTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -130,7 +158,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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt index 12aa9b79..b3d3e078 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt +++ b/orb-java-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") @@ -84,7 +108,7 @@ internal class NewPlanGroupedTieredPriceTest { assertThat(newPlanGroupedTieredPrice.conversionRate()).contains(0.0) assertThat(newPlanGroupedTieredPrice.conversionRateConfig()) .contains( - NewPlanGroupedTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt index 6360b97e..f135d930 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-java-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") @@ -87,7 +125,7 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { assertThat(newPlanGroupedWithMeteredMinimumPrice.conversionRate()).contains(0.0) assertThat(newPlanGroupedWithMeteredMinimumPrice.conversionRateConfig()) .contains( - NewPlanGroupedWithMeteredMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt index 63cd1b2b..b237e469 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt +++ b/orb-java-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") @@ -90,7 +94,7 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { assertThat(newPlanGroupedWithProratedMinimumPrice.conversionRate()).contains(0.0) assertThat(newPlanGroupedWithProratedMinimumPrice.conversionRateConfig()) .contains( - NewPlanGroupedWithProratedMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt index 2689a9de..789bb03b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt @@ -96,7 +96,7 @@ internal class NewPlanMatrixPriceTest { assertThat(newPlanMatrixPrice.conversionRate()).contains(0.0) assertThat(newPlanMatrixPrice.conversionRateConfig()) .contains( - NewPlanMatrixPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt index 2a7e30fe..53233108 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt +++ b/orb-java-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() @@ -101,7 +101,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { assertThat(newPlanMatrixWithAllocationPrice.conversionRate()).contains(0.0) assertThat(newPlanMatrixWithAllocationPrice.conversionRateConfig()) .contains( - NewPlanMatrixWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -147,11 +147,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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt index 23a3f0e4..1b1327df 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt +++ b/orb-java-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()) @@ -85,7 +101,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { assertThat(newPlanMatrixWithDisplayNamePrice.conversionRate()).contains(0.0) assertThat(newPlanMatrixWithDisplayNamePrice.conversionRateConfig()) .contains( - NewPlanMatrixWithDisplayNamePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt index 090e779c..4d366163 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt +++ b/orb-java-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()) @@ -85,7 +113,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { assertThat(newPlanMaxGroupTieredPackagePrice.conversionRate()).contains(0.0) assertThat(newPlanMaxGroupTieredPackagePrice.conversionRateConfig()) .contains( - NewPlanMaxGroupTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt similarity index 61% rename from orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt rename to orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt index 31c2f2b2..ff731e34 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTierWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt @@ -8,21 +8,22 @@ import com.withorb.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class NewPlanTierWithProrationPriceTest { +internal class NewPlanMinimumCompositePriceTest { @Test fun create() { - val newPlanTierWithProrationPrice = - NewPlanTierWithProrationPrice.builder() - .cadence(NewPlanTierWithProrationPrice.Cadence.ANNUAL) + val newPlanMinimumCompositePrice = + NewPlanMinimumCompositePrice.builder() + .cadence(NewPlanMinimumCompositePrice.Cadence.ANNUAL) .itemId("item_id") - .modelType(NewPlanTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - .name("Annual fee") - .tieredWithProrationConfig( - NewPlanTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .minimumConfig( + NewPlanMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) .build() ) + .modelType(NewPlanMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -53,38 +54,39 @@ internal class NewPlanTierWithProrationPriceTest { .build() ) .metadata( - NewPlanTierWithProrationPrice.Metadata.builder() + NewPlanMinimumCompositePrice.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()) + assertThat(newPlanMinimumCompositePrice.cadence()) + .isEqualTo(NewPlanMinimumCompositePrice.Cadence.ANNUAL) + assertThat(newPlanMinimumCompositePrice.itemId()).isEqualTo("item_id") + assertThat(newPlanMinimumCompositePrice.minimumConfig()) .isEqualTo( - NewPlanTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + NewPlanMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) .build() ) - assertThat(newPlanTierWithProrationPrice.billableMetricId()).contains("billable_metric_id") - assertThat(newPlanTierWithProrationPrice.billedInAdvance()).contains(true) - assertThat(newPlanTierWithProrationPrice.billingCycleConfiguration()) + assertThat(newPlanMinimumCompositePrice.modelType()) + .isEqualTo(NewPlanMinimumCompositePrice.ModelType.MINIMUM) + assertThat(newPlanMinimumCompositePrice.name()).isEqualTo("Annual fee") + assertThat(newPlanMinimumCompositePrice.billableMetricId()).contains("billable_metric_id") + assertThat(newPlanMinimumCompositePrice.billedInAdvance()).contains(true) + assertThat(newPlanMinimumCompositePrice.billingCycleConfiguration()) .contains( NewBillingCycleConfiguration.builder() .duration(0L) .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) - assertThat(newPlanTierWithProrationPrice.conversionRate()).contains(0.0) - assertThat(newPlanTierWithProrationPrice.conversionRateConfig()) + assertThat(newPlanMinimumCompositePrice.conversionRate()).contains(0.0) + assertThat(newPlanMinimumCompositePrice.conversionRateConfig()) .contains( - NewPlanTierWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -93,8 +95,8 @@ internal class NewPlanTierWithProrationPriceTest { .build() ) ) - assertThat(newPlanTierWithProrationPrice.currency()).contains("currency") - assertThat(newPlanTierWithProrationPrice.dimensionalPriceConfiguration()) + assertThat(newPlanMinimumCompositePrice.currency()).contains("currency") + assertThat(newPlanMinimumCompositePrice.dimensionalPriceConfiguration()) .contains( NewDimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -102,39 +104,40 @@ internal class NewPlanTierWithProrationPriceTest { .externalDimensionalPriceGroupId("external_dimensional_price_group_id") .build() ) - assertThat(newPlanTierWithProrationPrice.externalPriceId()).contains("external_price_id") - assertThat(newPlanTierWithProrationPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newPlanTierWithProrationPrice.invoiceGroupingKey()).contains("x") - assertThat(newPlanTierWithProrationPrice.invoicingCycleConfiguration()) + assertThat(newPlanMinimumCompositePrice.externalPriceId()).contains("external_price_id") + assertThat(newPlanMinimumCompositePrice.fixedPriceQuantity()).contains(0.0) + assertThat(newPlanMinimumCompositePrice.invoiceGroupingKey()).contains("x") + assertThat(newPlanMinimumCompositePrice.invoicingCycleConfiguration()) .contains( NewBillingCycleConfiguration.builder() .duration(0L) .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) - assertThat(newPlanTierWithProrationPrice.metadata()) + assertThat(newPlanMinimumCompositePrice.metadata()) .contains( - NewPlanTierWithProrationPrice.Metadata.builder() + NewPlanMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - assertThat(newPlanTierWithProrationPrice.referenceId()).contains("reference_id") + assertThat(newPlanMinimumCompositePrice.referenceId()).contains("reference_id") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val newPlanTierWithProrationPrice = - NewPlanTierWithProrationPrice.builder() - .cadence(NewPlanTierWithProrationPrice.Cadence.ANNUAL) + val newPlanMinimumCompositePrice = + NewPlanMinimumCompositePrice.builder() + .cadence(NewPlanMinimumCompositePrice.Cadence.ANNUAL) .itemId("item_id") - .modelType(NewPlanTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - .name("Annual fee") - .tieredWithProrationConfig( - NewPlanTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .minimumConfig( + NewPlanMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) .build() ) + .modelType(NewPlanMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -165,20 +168,19 @@ internal class NewPlanTierWithProrationPriceTest { .build() ) .metadata( - NewPlanTierWithProrationPrice.Metadata.builder() + NewPlanMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .referenceId("reference_id") .build() - val roundtrippedNewPlanTierWithProrationPrice = + val roundtrippedNewPlanMinimumCompositePrice = jsonMapper.readValue( - jsonMapper.writeValueAsString(newPlanTierWithProrationPrice), - jacksonTypeRef(), + jsonMapper.writeValueAsString(newPlanMinimumCompositePrice), + jacksonTypeRef(), ) - assertThat(roundtrippedNewPlanTierWithProrationPrice) - .isEqualTo(newPlanTierWithProrationPrice) + assertThat(roundtrippedNewPlanMinimumCompositePrice).isEqualTo(newPlanMinimumCompositePrice) } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt index 2fa6bad6..2b8f8db8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt +++ b/orb-java-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()).contains("billable_metric_id") assertThat(newPlanPackagePrice.billedInAdvance()).contains(true) @@ -78,7 +78,7 @@ internal class NewPlanPackagePriceTest { assertThat(newPlanPackagePrice.conversionRate()).contains(0.0) assertThat(newPlanPackagePrice.conversionRateConfig()) .contains( - NewPlanPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt index ca6d749e..06963f17 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +89,7 @@ internal class NewPlanPackageWithAllocationPriceTest { assertThat(newPlanPackageWithAllocationPrice.conversionRate()).contains(0.0) assertThat(newPlanPackageWithAllocationPrice.conversionRateConfig()) .contains( - NewPlanPackageWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt index c08b0d27..613d5e6f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-java-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()) @@ -96,7 +154,7 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { assertThat(newPlanScalableMatrixWithTieredPricingPrice.conversionRate()).contains(0.0) assertThat(newPlanScalableMatrixWithTieredPricingPrice.conversionRateConfig()) .contains( - NewPlanScalableMatrixWithTieredPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt index c5a04e9c..83a3eb80 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-java-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()) @@ -93,7 +119,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { assertThat(newPlanScalableMatrixWithUnitPricingPrice.conversionRate()).contains(0.0) assertThat(newPlanScalableMatrixWithUnitPricingPrice.conversionRateConfig()) .contains( - NewPlanScalableMatrixWithUnitPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -146,7 +172,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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt index 5f37e919..90357304 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +115,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { assertThat(newPlanThresholdTotalAmountPrice.conversionRate()).contains(0.0) assertThat(newPlanThresholdTotalAmountPrice.conversionRateConfig()) .contains( - NewPlanThresholdTotalAmountPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -133,7 +163,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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredBpsPriceTest.kt deleted file mode 100644 index 49da8a9e..00000000 --- a/orb-java-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()).contains("billable_metric_id") - assertThat(newPlanTieredBpsPrice.billedInAdvance()).contains(true) - assertThat(newPlanTieredBpsPrice.billingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanTieredBpsPrice.conversionRate()).contains(0.0) - assertThat(newPlanTieredBpsPrice.conversionRateConfig()) - .contains( - NewPlanTieredBpsPrice.ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newPlanTieredBpsPrice.currency()).contains("currency") - assertThat(newPlanTieredBpsPrice.dimensionalPriceConfiguration()) - .contains( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newPlanTieredBpsPrice.externalPriceId()).contains("external_price_id") - assertThat(newPlanTieredBpsPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newPlanTieredBpsPrice.invoiceGroupingKey()).contains("x") - assertThat(newPlanTieredBpsPrice.invoicingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newPlanTieredBpsPrice.metadata()) - .contains( - NewPlanTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newPlanTieredBpsPrice.referenceId()).contains("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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt index 6c7dca1d..35759c36 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt +++ b/orb-java-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()).contains("billable_metric_id") @@ -84,7 +108,7 @@ internal class NewPlanTieredPackagePriceTest { assertThat(newPlanTieredPackagePrice.conversionRate()).contains(0.0) assertThat(newPlanTieredPackagePrice.conversionRateConfig()) .contains( - NewPlanTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt index 21509959..7fad794b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt +++ b/orb-java-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()) @@ -87,7 +119,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { assertThat(newPlanTieredPackageWithMinimumPrice.conversionRate()).contains(0.0) assertThat(newPlanTieredPackageWithMinimumPrice.conversionRateConfig()) .contains( - NewPlanTieredPackageWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt index 893703a8..ce225df3 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt @@ -94,7 +94,7 @@ internal class NewPlanTieredPriceTest { assertThat(newPlanTieredPrice.conversionRate()).contains(0.0) assertThat(newPlanTieredPrice.conversionRateConfig()) .contains( - NewPlanTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt index 16f2e708..9cae1ad6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt +++ b/orb-java-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()).contains("billable_metric_id") @@ -84,7 +114,7 @@ internal class NewPlanTieredWithMinimumPriceTest { assertThat(newPlanTieredWithMinimumPrice.conversionRate()).contains(0.0) assertThat(newPlanTieredWithMinimumPrice.conversionRateConfig()) .contains( - NewPlanTieredWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt index d53af649..2a9e7996 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt @@ -74,7 +74,7 @@ internal class NewPlanUnitPriceTest { assertThat(newPlanUnitPrice.conversionRate()).contains(0.0) assertThat(newPlanUnitPrice.conversionRateConfig()) .contains( - NewPlanUnitPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt index 969304cd..0b4d1f7b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt +++ b/orb-java-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()).contains("billable_metric_id") @@ -84,7 +86,7 @@ internal class NewPlanUnitWithPercentPriceTest { assertThat(newPlanUnitWithPercentPrice.conversionRate()).contains(0.0) assertThat(newPlanUnitWithPercentPrice.conversionRateConfig()) .contains( - NewPlanUnitWithPercentPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt index 8b6987b4..0325b384 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt +++ b/orb-java-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()).contains("billable_metric_id") @@ -84,7 +84,7 @@ internal class NewPlanUnitWithProrationPriceTest { assertThat(newPlanUnitWithProrationPrice.conversionRate()).contains(0.0) assertThat(newPlanUnitWithProrationPrice.conversionRateConfig()) .contains( - NewPlanUnitWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBpsPriceTest.kt deleted file mode 100644 index 6224d666..00000000 --- a/orb-java-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()).contains("billable_metric_id") - assertThat(newSubscriptionBpsPrice.billedInAdvance()).contains(true) - assertThat(newSubscriptionBpsPrice.billingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionBpsPrice.conversionRate()).contains(0.0) - assertThat(newSubscriptionBpsPrice.conversionRateConfig()) - .contains( - NewSubscriptionBpsPrice.ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newSubscriptionBpsPrice.currency()).contains("currency") - assertThat(newSubscriptionBpsPrice.dimensionalPriceConfiguration()) - .contains( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newSubscriptionBpsPrice.externalPriceId()).contains("external_price_id") - assertThat(newSubscriptionBpsPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newSubscriptionBpsPrice.invoiceGroupingKey()).contains("x") - assertThat(newSubscriptionBpsPrice.invoicingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionBpsPrice.metadata()) - .contains( - NewSubscriptionBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newSubscriptionBpsPrice.referenceId()).contains("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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkBpsPriceTest.kt deleted file mode 100644 index 21a6d71e..00000000 --- a/orb-java-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()).contains("billable_metric_id") - assertThat(newSubscriptionBulkBpsPrice.billedInAdvance()).contains(true) - assertThat(newSubscriptionBulkBpsPrice.billingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionBulkBpsPrice.conversionRate()).contains(0.0) - assertThat(newSubscriptionBulkBpsPrice.conversionRateConfig()) - .contains( - NewSubscriptionBulkBpsPrice.ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newSubscriptionBulkBpsPrice.currency()).contains("currency") - assertThat(newSubscriptionBulkBpsPrice.dimensionalPriceConfiguration()) - .contains( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newSubscriptionBulkBpsPrice.externalPriceId()).contains("external_price_id") - assertThat(newSubscriptionBulkBpsPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newSubscriptionBulkBpsPrice.invoiceGroupingKey()).contains("x") - assertThat(newSubscriptionBulkBpsPrice.invoicingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionBulkBpsPrice.metadata()) - .contains( - NewSubscriptionBulkBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newSubscriptionBulkBpsPrice.referenceId()).contains("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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt index 62ec579b..6dded0f5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt @@ -86,7 +86,7 @@ internal class NewSubscriptionBulkPriceTest { assertThat(newSubscriptionBulkPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionBulkPrice.conversionRateConfig()) .contains( - NewSubscriptionBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt index d265f4e7..86c0346b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +109,7 @@ internal class NewSubscriptionBulkWithProrationPriceTest { assertThat(newSubscriptionBulkWithProrationPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionBulkWithProrationPrice.conversionRateConfig()) .contains( - NewSubscriptionBulkWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt index 8a33b86c..d04f7ee3 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt +++ b/orb-java-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") @@ -87,7 +105,7 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { assertThat(newSubscriptionCumulativeGroupedBulkPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionCumulativeGroupedBulkPrice.conversionRateConfig()) .contains( - NewSubscriptionCumulativeGroupedBulkPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -133,7 +151,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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt index 213542a1..2bad026b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt +++ b/orb-java-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") @@ -85,7 +89,7 @@ internal class NewSubscriptionGroupedAllocationPriceTest { assertThat(newSubscriptionGroupedAllocationPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionGroupedAllocationPrice.conversionRateConfig()) .contains( - NewSubscriptionGroupedAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt index 138c9e67..35e11178 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt +++ b/orb-java-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") @@ -87,7 +117,7 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { assertThat(newSubscriptionGroupedTieredPackagePrice.conversionRate()).contains(0.0) assertThat(newSubscriptionGroupedTieredPackagePrice.conversionRateConfig()) .contains( - NewSubscriptionGroupedTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt index 76aed0b2..d74b508a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt +++ b/orb-java-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") @@ -85,7 +109,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { assertThat(newSubscriptionGroupedTieredPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionGroupedTieredPrice.conversionRateConfig()) .contains( - NewSubscriptionGroupedTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt index e9456d00..122ebb77 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-java-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") @@ -92,7 +134,7 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.conversionRateConfig()) .contains( - NewSubscriptionGroupedWithMeteredMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -140,7 +182,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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt index 59c743c8..f82dd106 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt +++ b/orb-java-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") @@ -95,7 +99,7 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { assertThat(newSubscriptionGroupedWithProratedMinimumPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionGroupedWithProratedMinimumPrice.conversionRateConfig()) .contains( - NewSubscriptionGroupedWithProratedMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt index fb371835..2c6dac33 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt @@ -98,7 +98,7 @@ internal class NewSubscriptionMatrixPriceTest { assertThat(newSubscriptionMatrixPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionMatrixPrice.conversionRateConfig()) .contains( - NewSubscriptionMatrixPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt index e8ba1271..5ac3dfef 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt +++ b/orb-java-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() @@ -103,7 +103,7 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { assertThat(newSubscriptionMatrixWithAllocationPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionMatrixWithAllocationPrice.conversionRateConfig()) .contains( - NewSubscriptionMatrixWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt index 92c751e4..6ed09c6a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt +++ b/orb-java-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()) @@ -87,7 +105,7 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { assertThat(newSubscriptionMatrixWithDisplayNamePrice.conversionRate()).contains(0.0) assertThat(newSubscriptionMatrixWithDisplayNamePrice.conversionRateConfig()) .contains( - NewSubscriptionMatrixWithDisplayNamePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -134,7 +152,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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt index 1901dc93..4ebf6136 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt +++ b/orb-java-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()) @@ -87,7 +119,7 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { assertThat(newSubscriptionMaxGroupTieredPackagePrice.conversionRate()).contains(0.0) assertThat(newSubscriptionMaxGroupTieredPackagePrice.conversionRateConfig()) .contains( - NewSubscriptionMaxGroupTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -134,7 +166,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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt similarity index 60% rename from orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt rename to orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt index bda05509..3be1d7b4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTierWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt @@ -8,21 +8,22 @@ import com.withorb.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class NewSubscriptionTierWithProrationPriceTest { +internal class NewSubscriptionMinimumCompositePriceTest { @Test fun create() { - val newSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice.builder() - .cadence(NewSubscriptionTierWithProrationPrice.Cadence.ANNUAL) + val newSubscriptionMinimumCompositePrice = + NewSubscriptionMinimumCompositePrice.builder() + .cadence(NewSubscriptionMinimumCompositePrice.Cadence.ANNUAL) .itemId("item_id") - .modelType(NewSubscriptionTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - .name("Annual fee") - .tieredWithProrationConfig( - NewSubscriptionTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .minimumConfig( + NewSubscriptionMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) .build() ) + .modelType(NewSubscriptionMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -53,39 +54,40 @@ internal class NewSubscriptionTierWithProrationPriceTest { .build() ) .metadata( - NewSubscriptionTierWithProrationPrice.Metadata.builder() + NewSubscriptionMinimumCompositePrice.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()) + assertThat(newSubscriptionMinimumCompositePrice.cadence()) + .isEqualTo(NewSubscriptionMinimumCompositePrice.Cadence.ANNUAL) + assertThat(newSubscriptionMinimumCompositePrice.itemId()).isEqualTo("item_id") + assertThat(newSubscriptionMinimumCompositePrice.minimumConfig()) .isEqualTo( - NewSubscriptionTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + NewSubscriptionMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) .build() ) - assertThat(newSubscriptionTierWithProrationPrice.billableMetricId()) + assertThat(newSubscriptionMinimumCompositePrice.modelType()) + .isEqualTo(NewSubscriptionMinimumCompositePrice.ModelType.MINIMUM) + assertThat(newSubscriptionMinimumCompositePrice.name()).isEqualTo("Annual fee") + assertThat(newSubscriptionMinimumCompositePrice.billableMetricId()) .contains("billable_metric_id") - assertThat(newSubscriptionTierWithProrationPrice.billedInAdvance()).contains(true) - assertThat(newSubscriptionTierWithProrationPrice.billingCycleConfiguration()) + assertThat(newSubscriptionMinimumCompositePrice.billedInAdvance()).contains(true) + assertThat(newSubscriptionMinimumCompositePrice.billingCycleConfiguration()) .contains( NewBillingCycleConfiguration.builder() .duration(0L) .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) - assertThat(newSubscriptionTierWithProrationPrice.conversionRate()).contains(0.0) - assertThat(newSubscriptionTierWithProrationPrice.conversionRateConfig()) + assertThat(newSubscriptionMinimumCompositePrice.conversionRate()).contains(0.0) + assertThat(newSubscriptionMinimumCompositePrice.conversionRateConfig()) .contains( - NewSubscriptionTierWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -94,8 +96,8 @@ internal class NewSubscriptionTierWithProrationPriceTest { .build() ) ) - assertThat(newSubscriptionTierWithProrationPrice.currency()).contains("currency") - assertThat(newSubscriptionTierWithProrationPrice.dimensionalPriceConfiguration()) + assertThat(newSubscriptionMinimumCompositePrice.currency()).contains("currency") + assertThat(newSubscriptionMinimumCompositePrice.dimensionalPriceConfiguration()) .contains( NewDimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -103,40 +105,41 @@ internal class NewSubscriptionTierWithProrationPriceTest { .externalDimensionalPriceGroupId("external_dimensional_price_group_id") .build() ) - assertThat(newSubscriptionTierWithProrationPrice.externalPriceId()) + assertThat(newSubscriptionMinimumCompositePrice.externalPriceId()) .contains("external_price_id") - assertThat(newSubscriptionTierWithProrationPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newSubscriptionTierWithProrationPrice.invoiceGroupingKey()).contains("x") - assertThat(newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration()) + assertThat(newSubscriptionMinimumCompositePrice.fixedPriceQuantity()).contains(0.0) + assertThat(newSubscriptionMinimumCompositePrice.invoiceGroupingKey()).contains("x") + assertThat(newSubscriptionMinimumCompositePrice.invoicingCycleConfiguration()) .contains( NewBillingCycleConfiguration.builder() .duration(0L) .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) - assertThat(newSubscriptionTierWithProrationPrice.metadata()) + assertThat(newSubscriptionMinimumCompositePrice.metadata()) .contains( - NewSubscriptionTierWithProrationPrice.Metadata.builder() + NewSubscriptionMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - assertThat(newSubscriptionTierWithProrationPrice.referenceId()).contains("reference_id") + assertThat(newSubscriptionMinimumCompositePrice.referenceId()).contains("reference_id") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val newSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice.builder() - .cadence(NewSubscriptionTierWithProrationPrice.Cadence.ANNUAL) + val newSubscriptionMinimumCompositePrice = + NewSubscriptionMinimumCompositePrice.builder() + .cadence(NewSubscriptionMinimumCompositePrice.Cadence.ANNUAL) .itemId("item_id") - .modelType(NewSubscriptionTierWithProrationPrice.ModelType.TIERED_WITH_PRORATION) - .name("Annual fee") - .tieredWithProrationConfig( - NewSubscriptionTierWithProrationPrice.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .minimumConfig( + NewSubscriptionMinimumCompositePrice.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) .build() ) + .modelType(NewSubscriptionMinimumCompositePrice.ModelType.MINIMUM) + .name("Annual fee") .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( @@ -167,20 +170,20 @@ internal class NewSubscriptionTierWithProrationPriceTest { .build() ) .metadata( - NewSubscriptionTierWithProrationPrice.Metadata.builder() + NewSubscriptionMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .referenceId("reference_id") .build() - val roundtrippedNewSubscriptionTierWithProrationPrice = + val roundtrippedNewSubscriptionMinimumCompositePrice = jsonMapper.readValue( - jsonMapper.writeValueAsString(newSubscriptionTierWithProrationPrice), - jacksonTypeRef(), + jsonMapper.writeValueAsString(newSubscriptionMinimumCompositePrice), + jacksonTypeRef(), ) - assertThat(roundtrippedNewSubscriptionTierWithProrationPrice) - .isEqualTo(newSubscriptionTierWithProrationPrice) + assertThat(roundtrippedNewSubscriptionMinimumCompositePrice) + .isEqualTo(newSubscriptionMinimumCompositePrice) } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt index dbf9f1ab..16926263 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt +++ b/orb-java-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()).contains("billable_metric_id") assertThat(newSubscriptionPackagePrice.billedInAdvance()).contains(true) @@ -80,7 +80,7 @@ internal class NewSubscriptionPackagePriceTest { assertThat(newSubscriptionPackagePrice.conversionRate()).contains(0.0) assertThat(newSubscriptionPackagePrice.conversionRateConfig()) .contains( - NewSubscriptionPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt index 8a0d30a6..0a6d6087 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt +++ b/orb-java-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()) @@ -87,7 +91,7 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { assertThat(newSubscriptionPackageWithAllocationPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionPackageWithAllocationPrice.conversionRateConfig()) .contains( - NewSubscriptionPackageWithAllocationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -138,7 +142,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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt index f4b99606..ddc35702 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-java-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()) @@ -102,7 +160,7 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .contains(0.0) assertThat(newSubscriptionScalableMatrixWithTieredPricingPrice.conversionRateConfig()) .contains( - NewSubscriptionScalableMatrixWithTieredPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt index 3dd41284..312ab4b2 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-java-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()) @@ -99,7 +125,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.conversionRateConfig()) .contains( - NewSubscriptionScalableMatrixWithUnitPricingPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -159,7 +185,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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt index 93a9f607..d002d94c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt +++ b/orb-java-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()) @@ -87,7 +119,7 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { assertThat(newSubscriptionThresholdTotalAmountPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionThresholdTotalAmountPrice.conversionRateConfig()) .contains( - NewSubscriptionThresholdTotalAmountPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredBpsPriceTest.kt deleted file mode 100644 index 42819e05..00000000 --- a/orb-java-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()).contains("billable_metric_id") - assertThat(newSubscriptionTieredBpsPrice.billedInAdvance()).contains(true) - assertThat(newSubscriptionTieredBpsPrice.billingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionTieredBpsPrice.conversionRate()).contains(0.0) - assertThat(newSubscriptionTieredBpsPrice.conversionRateConfig()) - .contains( - NewSubscriptionTieredBpsPrice.ConversionRateConfig.ofUnit( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .build() - ) - ) - assertThat(newSubscriptionTieredBpsPrice.currency()).contains("currency") - assertThat(newSubscriptionTieredBpsPrice.dimensionalPriceConfiguration()) - .contains( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) - assertThat(newSubscriptionTieredBpsPrice.externalPriceId()).contains("external_price_id") - assertThat(newSubscriptionTieredBpsPrice.fixedPriceQuantity()).contains(0.0) - assertThat(newSubscriptionTieredBpsPrice.invoiceGroupingKey()).contains("x") - assertThat(newSubscriptionTieredBpsPrice.invoicingCycleConfiguration()) - .contains( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - assertThat(newSubscriptionTieredBpsPrice.metadata()) - .contains( - NewSubscriptionTieredBpsPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(newSubscriptionTieredBpsPrice.referenceId()).contains("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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt index 032bcaaa..0357b619 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt +++ b/orb-java-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()) @@ -85,7 +109,7 @@ internal class NewSubscriptionTieredPackagePriceTest { assertThat(newSubscriptionTieredPackagePrice.conversionRate()).contains(0.0) assertThat(newSubscriptionTieredPackagePrice.conversionRateConfig()) .contains( - NewSubscriptionTieredPackagePrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt index 06bcb458..110d066f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt +++ b/orb-java-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()) @@ -92,7 +130,7 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { assertThat(newSubscriptionTieredPackageWithMinimumPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionTieredPackageWithMinimumPrice.conversionRateConfig()) .contains( - NewSubscriptionTieredPackageWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt index 42afbae1..918eef6f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt @@ -96,7 +96,7 @@ internal class NewSubscriptionTieredPriceTest { assertThat(newSubscriptionTieredPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionTieredPrice.conversionRateConfig()) .contains( - NewSubscriptionTieredPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt index 0cf9969b..82203307 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +117,7 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { assertThat(newSubscriptionTieredWithMinimumPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionTieredWithMinimumPrice.conversionRateConfig()) .contains( - NewSubscriptionTieredWithMinimumPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt index 2ed50bcd..9247fd95 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt @@ -76,7 +76,7 @@ internal class NewSubscriptionUnitPriceTest { assertThat(newSubscriptionUnitPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionUnitPrice.conversionRateConfig()) .contains( - NewSubscriptionUnitPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt index 6c183a09..dee30f50 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +87,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { assertThat(newSubscriptionUnitWithPercentPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionUnitWithPercentPrice.conversionRateConfig()) .contains( - NewSubscriptionUnitWithPercentPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt index 1e1565cf..9dd1ce78 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt +++ b/orb-java-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()) @@ -85,7 +85,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { assertThat(newSubscriptionUnitWithProrationPrice.conversionRate()).contains(0.0) assertThat(newSubscriptionUnitWithProrationPrice.conversionRateConfig()) .contains( - NewSubscriptionUnitWithProrationPrice.ConversionRateConfig.ofUnit( + ConversionRateConfig.ofUnit( UnitConversionRateConfig.builder() .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) .unitConfig( @@ -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-java-core/src/test/kotlin/com/withorb/api/models/PackageConfigTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PackageConfigTest.kt index 9a21cd29..e615c4bd 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PackageConfigTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 510507c6..8c029113 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -25,7 +25,15 @@ internal class PerPriceCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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,7 +141,15 @@ internal class PerPriceCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -245,7 +261,15 @@ internal class PerPriceCostTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index c54feb68..7e8669f2 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -168,7 +168,15 @@ internal class PlanListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -436,7 +444,15 @@ internal class PlanListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -705,7 +721,15 @@ internal class PlanListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index e13a2832..c1f3d46f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -167,7 +167,15 @@ internal class PlanTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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,7 +446,15 @@ internal class PlanTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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,7 +720,15 @@ internal class PlanTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 5b8c6148..3a201c30 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -58,7 +58,15 @@ internal class PlanVersionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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,7 +208,15 @@ internal class PlanVersionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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,7 +357,15 @@ internal class PlanVersionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index 0c829855..971c2d5a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -39,7 +39,15 @@ internal class PriceIntervalTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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,7 +170,15 @@ internal class PriceIntervalTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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,7 +302,15 @@ internal class PriceIntervalTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index fcecceb0..70fec704 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -25,7 +25,15 @@ internal class PriceListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -132,7 +140,15 @@ internal class PriceListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -242,7 +258,15 @@ internal class PriceListPageResponseTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 76fbac95..e17deb4a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -27,7 +27,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -120,17 +128,14 @@ internal class PriceTest { val price = Price.ofUnit(unit) assertThat(price.unit()).contains(unit) - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -138,16 +143,19 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test @@ -164,7 +172,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -262,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( @@ -273,7 +289,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Package.Cadence.ONE_TIME) + .billingMode(Price.Tiered.BillingMode.IN_ADVANCE) + .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() @@ -332,7 +356,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Package.Metadata.builder() + Price.Tiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -351,12 +375,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") @@ -365,20 +397,17 @@ internal class PriceTest { ) .build() - val price = Price.ofPackage(package_) + val price = Price.ofTiered(tiered) assertThat(price.unit()).isEmpty - assertThat(price.package_()).contains(package_) - assertThat(price.matrix()).isEmpty - assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty + assertThat(price.tiered()).contains(tiered) assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -386,24 +415,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @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( @@ -412,7 +444,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Package.Cadence.ONE_TIME) + .billingMode(Price.Tiered.BillingMode.IN_ADVANCE) + .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() @@ -471,7 +511,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Package.Metadata.builder() + Price.Tiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -490,15 +530,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") @@ -515,9 +560,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( @@ -526,7 +571,22 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Matrix.Cadence.ONE_TIME) + .billingMode(Price.Bulk.BillingMode.IN_ADVANCE) + .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() @@ -570,18 +630,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") @@ -597,7 +645,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Matrix.Metadata.builder() + Price.Bulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -617,7 +665,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() @@ -627,20 +675,17 @@ internal class PriceTest { ) .build() - val price = Price.ofMatrix(matrix) + val price = Price.ofBulk(bulk) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).contains(matrix) assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty - assertThat(price.bulk()).isEmpty + assertThat(price.bulk()).contains(bulk) + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -648,24 +693,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @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( @@ -674,7 +722,25 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Matrix.Cadence.ONE_TIME) + .billingMode(Price.Bulk.BillingMode.IN_ADVANCE) + .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() @@ -718,18 +784,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") @@ -745,7 +799,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Matrix.Metadata.builder() + Price.Bulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -765,7 +819,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() @@ -783,9 +837,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( @@ -794,7 +848,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Tiered.Cadence.ONE_TIME) + .billingMode(Price.Package.BillingMode.IN_ADVANCE) + .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() @@ -853,7 +915,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Tiered.Metadata.builder() + Price.Package.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -872,20 +934,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") @@ -894,20 +948,17 @@ internal class PriceTest { ) .build() - val price = Price.ofTiered(tiered) + val price = Price.ofPackage(package_) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty - assertThat(price.tiered()).contains(tiered) - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty + assertThat(price.tiered()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).contains(package_) + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -915,24 +966,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @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( @@ -941,7 +995,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.Tiered.Cadence.ONE_TIME) + .billingMode(Price.Package.BillingMode.IN_ADVANCE) + .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() @@ -1000,7 +1062,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Tiered.Metadata.builder() + Price.Package.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1019,20 +1081,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") @@ -1049,9 +1106,9 @@ internal class PriceTest { } @Test - fun ofTieredBps() { - val tieredBps = - Price.TieredBps.builder() + fun ofMatrix() { + val matrix = + Price.Matrix.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1060,7 +1117,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredBps.Cadence.ONE_TIME) + .billingMode(Price.Matrix.BillingMode.IN_ADVANCE) + .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() @@ -1104,22 +1169,34 @@ internal class PriceTest { .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") + .matrixConfig( + MatrixConfig.builder() + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .addMatrixValue( + MatrixValue.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + .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.TieredBps.Metadata.builder() + Price.Matrix.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1139,20 +1216,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredBps.PriceType.USAGE_PRICE) + .priceType(Price.Matrix.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,20 +1226,17 @@ internal class PriceTest { ) .build() - val price = Price.ofTieredBps(tieredBps) + val price = Price.ofMatrix(matrix) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).contains(tieredBps) - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).contains(matrix) assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -1182,24 +1244,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofTieredBpsRoundtrip() { + fun ofMatrixRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofTieredBps( - Price.TieredBps.builder() + Price.ofMatrix( + Price.Matrix.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1208,7 +1273,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredBps.Cadence.ONE_TIME) + .billingMode(Price.Matrix.BillingMode.IN_ADVANCE) + .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() @@ -1252,6 +1325,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") @@ -1267,7 +1352,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredBps.Metadata.builder() + Price.Matrix.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1287,20 +1372,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredBps.PriceType.USAGE_PRICE) + .priceType(Price.Matrix.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 +1390,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 +1401,15 @@ 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) + .billingMode(Price.ThresholdTotalAmount.BillingMode.IN_ADVANCE) + .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 +1468,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bps.Metadata.builder() + Price.ThresholdTotalAmount.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1408,8 +1488,27 @@ 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() + .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( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1418,20 +1517,17 @@ internal class PriceTest { ) .build() - val price = Price.ofBps(bps) + val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).contains(bps) - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty - assertThat(price.thresholdTotalAmount()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty + assertThat(price.thresholdTotalAmount()).contains(thresholdTotalAmount) assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -1439,24 +1535,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @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 +1564,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bpsConfig( - BpsConfig.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build() + .billingMode(Price.ThresholdTotalAmount.BillingMode.IN_ADVANCE) + .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 +1631,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bps.Metadata.builder() + Price.ThresholdTotalAmount.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1547,8 +1651,29 @@ 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() + .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( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1565,9 +1690,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 +1701,15 @@ 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() - ) + .billingMode(Price.TieredPackage.BillingMode.IN_ADVANCE) + .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 +1768,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkBps.Metadata.builder() + Price.TieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1666,8 +1788,25 @@ 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() + .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( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1676,20 +1815,17 @@ internal class PriceTest { ) .build() - val price = Price.ofBulkBps(bulkBps) + val price = Price.ofTieredPackage(tieredPackage) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).contains(bulkBps) assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty - assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty + assertThat(price.tieredPackage()).contains(tieredPackage) assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -1697,24 +1833,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @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 +1862,15 @@ 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() - ) + .billingMode(Price.TieredPackage.BillingMode.IN_ADVANCE) + .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 +1929,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkBps.Metadata.builder() + Price.TieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1813,8 +1949,25 @@ 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() + .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( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -1831,9 +1984,9 @@ internal class PriceTest { } @Test - fun ofBulk() { - val bulk = - Price.Bulk.builder() + fun ofTieredWithMinimum() { + val tieredWithMinimum = + Price.TieredWithMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1842,14 +1995,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkConfig( - BulkConfig.builder() - .addTier( - BulkTier.builder().unitAmount("unit_amount").maximumUnits(0.0).build() - ) + .billingMode(Price.TieredWithMinimum.BillingMode.IN_ADVANCE) + .cadence(Price.TieredWithMinimum.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() @@ -1908,7 +2062,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bulk.Metadata.builder() + Price.TieredWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -1928,8 +2082,28 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Bulk.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") @@ -1938,20 +2112,17 @@ internal class PriceTest { ) .build() - val price = Price.ofBulk(bulk) + val price = Price.ofTieredWithMinimum(tieredWithMinimum) assertThat(price.unit()).isEmpty + assertThat(price.tiered()).isEmpty + assertThat(price.bulk()).isEmpty assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty - assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty - assertThat(price.bulk()).contains(bulk) assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty + assertThat(price.tieredWithMinimum()).contains(tieredWithMinimum) assertThat(price.groupedTiered()).isEmpty - assertThat(price.tieredWithMinimum()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -1959,24 +2130,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofBulkRoundtrip() { + fun ofTieredWithMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofBulk( - Price.Bulk.builder() + Price.ofTieredWithMinimum( + Price.TieredWithMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -1985,17 +2159,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkConfig( - BulkConfig.builder() - .addTier( - BulkTier.builder() - .unitAmount("unit_amount") - .maximumUnits(0.0) - .build() - ) + .billingMode(Price.TieredWithMinimum.BillingMode.IN_ADVANCE) + .cadence(Price.TieredWithMinimum.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() @@ -2054,7 +2226,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.Bulk.Metadata.builder() + Price.TieredWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2074,8 +2246,28 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.Bulk.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") @@ -2092,9 +2284,9 @@ internal class PriceTest { } @Test - fun ofThresholdTotalAmount() { - val thresholdTotalAmount = - Price.ThresholdTotalAmount.builder() + fun ofGroupedTiered() { + val groupedTiered = + Price.GroupedTiered.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2103,7 +2295,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) + .billingMode(Price.GroupedTiered.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedTiered.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() @@ -2140,12 +2340,29 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) + .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) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) .item(ItemSlim.builder().id("id").name("name").build()) .maximum( Maximum.builder() @@ -2162,7 +2379,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ThresholdTotalAmount.Metadata.builder() + Price.GroupedTiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2182,13 +2399,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ThresholdTotalAmount.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .thresholdTotalAmountConfig( - Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2197,20 +2409,17 @@ internal class PriceTest { ) .build() - val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) + val price = Price.ofGroupedTiered(groupedTiered) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty - assertThat(price.thresholdTotalAmount()).contains(thresholdTotalAmount) + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty + assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).contains(groupedTiered) assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -2218,24 +2427,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofThresholdTotalAmountRoundtrip() { + fun ofGroupedTieredRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofThresholdTotalAmount( - Price.ThresholdTotalAmount.builder() + Price.ofGroupedTiered( + Price.GroupedTiered.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2244,7 +2456,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) + .billingMode(Price.GroupedTiered.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedTiered.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() @@ -2281,6 +2501,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) @@ -2303,7 +2540,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ThresholdTotalAmount.Metadata.builder() + Price.GroupedTiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2323,13 +2560,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ThresholdTotalAmount.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .thresholdTotalAmountConfig( - Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -2346,9 +2578,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 +2589,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredPackage.Cadence.ONE_TIME) + .billingMode(Price.TieredPackageWithMinimum.BillingMode.IN_ADVANCE) + .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 +2656,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackage.Metadata.builder() + Price.TieredPackageWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2436,11 +2676,27 @@ 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() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .tieredPackageWithMinimumConfig( + Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() + .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( @@ -2451,45 +2707,45 @@ internal class PriceTest { ) .build() - val price = Price.ofTieredPackage(tieredPackage) + val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty - assertThat(price.tieredPackage()).contains(tieredPackage) - assertThat(price.groupedTiered()).isEmpty + assertThat(price.tieredPackage()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty - assertThat(price.tieredPackageWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty + assertThat(price.tieredPackageWithMinimum()).contains(tieredPackageWithMinimum) assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @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 +2754,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredPackage.Cadence.ONE_TIME) + .billingMode(Price.TieredPackageWithMinimum.BillingMode.IN_ADVANCE) + .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 +2821,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackage.Metadata.builder() + Price.TieredPackageWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2577,11 +2841,27 @@ 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() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .tieredPackageWithMinimumConfig( + Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() + .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( @@ -2600,9 +2880,9 @@ internal class PriceTest { } @Test - fun ofGroupedTiered() { - val groupedTiered = - Price.GroupedTiered.builder() + fun ofPackageWithAllocation() { + val packageWithAllocation = + Price.PackageWithAllocation.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2611,7 +2891,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedTiered.Cadence.ONE_TIME) + .billingMode(Price.PackageWithAllocation.BillingMode.IN_ADVANCE) + .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() @@ -2648,11 +2936,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) @@ -2675,7 +2958,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTiered.Metadata.builder() + Price.PackageWithAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2694,8 +2977,15 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") + .packageWithAllocationConfig( + Price.PackageWithAllocation.PackageWithAllocationConfig.builder() + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") + .build() + ) .planPhaseOrder(0L) - .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) + .priceType(Price.PackageWithAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2705,45 +2995,45 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedTiered(groupedTiered) + val price = Price.ofPackageWithAllocation(packageWithAllocation) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).contains(groupedTiered) assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty - assertThat(price.packageWithAllocation()).isEmpty + assertThat(price.packageWithAllocation()).contains(packageWithAllocation) assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedTieredRoundtrip() { + fun ofPackageWithAllocationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedTiered( - Price.GroupedTiered.builder() + Price.ofPackageWithAllocation( + Price.PackageWithAllocation.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2752,7 +3042,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedTiered.Cadence.ONE_TIME) + .billingMode(Price.PackageWithAllocation.BillingMode.IN_ADVANCE) + .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() @@ -2789,11 +3087,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) @@ -2816,7 +3109,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTiered.Metadata.builder() + Price.PackageWithAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2835,8 +3128,15 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") + .packageWithAllocationConfig( + Price.PackageWithAllocation.PackageWithAllocationConfig.builder() + .allocation("allocation") + .packageAmount("package_amount") + .packageSize("package_size") + .build() + ) .planPhaseOrder(0L) - .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) + .priceType(Price.PackageWithAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -2854,9 +3154,9 @@ internal class PriceTest { } @Test - fun ofTieredWithMinimum() { - val tieredWithMinimum = - Price.TieredWithMinimum.builder() + fun ofUnitWithPercent() { + val unitWithPercent = + Price.UnitWithPercent.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -2865,7 +3165,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) + .billingMode(Price.UnitWithPercent.BillingMode.IN_ADVANCE) + .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() @@ -2924,7 +3232,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithMinimum.Metadata.builder() + Price.UnitWithPercent.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -2944,11 +3252,12 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithPercent.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredWithMinimumConfig( - Price.TieredWithMinimum.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitWithPercentConfig( + Price.UnitWithPercent.UnitWithPercentConfig.builder() + .percent("percent") + .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( @@ -2959,45 +3268,45 @@ internal class PriceTest { ) .build() - val price = Price.ofTieredWithMinimum(tieredWithMinimum) + val price = Price.ofUnitWithPercent(unitWithPercent) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty + assertThat(price.tieredWithMinimum()).isEmpty assertThat(price.groupedTiered()).isEmpty - assertThat(price.tieredWithMinimum()).contains(tieredWithMinimum) assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty - assertThat(price.unitWithPercent()).isEmpty + assertThat(price.unitWithPercent()).contains(unitWithPercent) assertThat(price.matrixWithAllocation()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofTieredWithMinimumRoundtrip() { + fun ofUnitWithPercentRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofTieredWithMinimum( - Price.TieredWithMinimum.builder() + Price.ofUnitWithPercent( + Price.UnitWithPercent.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -3006,7 +3315,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) + .billingMode(Price.UnitWithPercent.BillingMode.IN_ADVANCE) + .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() @@ -3065,7 +3382,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithMinimum.Metadata.builder() + Price.UnitWithPercent.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3085,11 +3402,12 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithPercent.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredWithMinimumConfig( - Price.TieredWithMinimum.TieredWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitWithPercentConfig( + Price.UnitWithPercent.UnitWithPercentConfig.builder() + .percent("percent") + .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( @@ -3108,9 +3426,9 @@ internal class PriceTest { } @Test - fun ofTieredPackageWithMinimum() { - val tieredPackageWithMinimum = - Price.TieredPackageWithMinimum.builder() + fun ofMatrixWithAllocation() { + val matrixWithAllocation = + Price.MatrixWithAllocation.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -3119,9 +3437,17 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) - .conversionRate(0.0) - .unitConversionRateConfig( + .billingMode(Price.MatrixWithAllocation.BillingMode.IN_ADVANCE) + .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() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -3163,6 +3489,19 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixWithAllocationConfig( + MatrixWithAllocationConfig.builder() + .allocation("allocation") + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .addMatrixValue( + MatrixWithAllocationConfig.MatrixValue.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -3178,7 +3517,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackageWithMinimum.Metadata.builder() + Price.MatrixWithAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3198,13 +3537,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPackageWithMinimum.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredPackageWithMinimumConfig( - Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -3213,45 +3547,45 @@ internal class PriceTest { ) .build() - val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + val price = Price.ofMatrixWithAllocation(matrixWithAllocation) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty - assertThat(price.tieredPackageWithMinimum()).contains(tieredPackageWithMinimum) + assertThat(price.groupedTiered()).isEmpty + assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty - assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithAllocation()).contains(matrixWithAllocation) assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofTieredPackageWithMinimumRoundtrip() { + fun ofMatrixWithAllocationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofTieredPackageWithMinimum( - Price.TieredPackageWithMinimum.builder() + Price.ofMatrixWithAllocation( + Price.MatrixWithAllocation.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -3260,7 +3594,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) + .billingMode(Price.MatrixWithAllocation.BillingMode.IN_ADVANCE) + .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() @@ -3304,6 +3646,19 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixWithAllocationConfig( + MatrixWithAllocationConfig.builder() + .allocation("allocation") + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .addMatrixValue( + MatrixWithAllocationConfig.MatrixValue.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -3319,7 +3674,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackageWithMinimum.Metadata.builder() + Price.MatrixWithAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3339,13 +3694,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPackageWithMinimum.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredPackageWithMinimumConfig( - Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -3362,9 +3712,9 @@ internal class PriceTest { } @Test - fun ofPackageWithAllocation() { - val packageWithAllocation = - Price.PackageWithAllocation.builder() + fun ofTieredWithProration() { + val tieredWithProration = + Price.TieredWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -3373,7 +3723,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) + .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) + .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() @@ -3432,7 +3790,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.PackageWithAllocation.Metadata.builder() + Price.TieredWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3451,14 +3809,19 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") - .packageWithAllocationConfig( - Price.PackageWithAllocation.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .planPhaseOrder(0L) - .priceType(Price.PackageWithAllocation.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .tieredWithProrationConfig( + Price.TieredWithProration.TieredWithProrationConfig.builder() + .addTier( + Price.TieredWithProration.TieredWithProrationConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -3467,45 +3830,45 @@ internal class PriceTest { ) .build() - val price = Price.ofPackageWithAllocation(packageWithAllocation) + val price = Price.ofTieredWithProration(tieredWithProration) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty - assertThat(price.packageWithAllocation()).contains(packageWithAllocation) + assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty - assertThat(price.tieredWithProration()).isEmpty + assertThat(price.tieredWithProration()).contains(tieredWithProration) assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofPackageWithAllocationRoundtrip() { + fun ofTieredWithProrationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofPackageWithAllocation( - Price.PackageWithAllocation.builder() + Price.ofTieredWithProration( + Price.TieredWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -3514,7 +3877,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) + .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) + .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() @@ -3573,7 +3944,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.PackageWithAllocation.Metadata.builder() + Price.TieredWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3592,14 +3963,19 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") - .packageWithAllocationConfig( - Price.PackageWithAllocation.PackageWithAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .planPhaseOrder(0L) - .priceType(Price.PackageWithAllocation.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .tieredWithProrationConfig( + Price.TieredWithProration.TieredWithProrationConfig.builder() + .addTier( + Price.TieredWithProration.TieredWithProrationConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -3616,9 +3992,9 @@ internal class PriceTest { } @Test - fun ofUnitWithPercent() { - val unitWithPercent = - Price.UnitWithPercent.builder() + fun ofUnitWithProration() { + val unitWithProration = + Price.UnitWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -3627,7 +4003,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) + .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) + .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() @@ -3686,7 +4070,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithPercent.Metadata.builder() + Price.UnitWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3706,11 +4090,11 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithPercent.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitWithPercentConfig( - Price.UnitWithPercent.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitWithProrationConfig( + Price.UnitWithProration.UnitWithProrationConfig.builder() + .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( @@ -3721,45 +4105,45 @@ internal class PriceTest { ) .build() - val price = Price.ofUnitWithPercent(unitWithPercent) + val price = Price.ofUnitWithProration(unitWithProration) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty - assertThat(price.unitWithPercent()).contains(unitWithPercent) + assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty assertThat(price.tieredWithProration()).isEmpty - assertThat(price.unitWithProration()).isEmpty + assertThat(price.unitWithProration()).contains(unitWithProration) assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofUnitWithPercentRoundtrip() { + fun ofUnitWithProrationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofUnitWithPercent( - Price.UnitWithPercent.builder() + Price.ofUnitWithProration( + Price.UnitWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -3768,7 +4152,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) + .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) + .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() @@ -3827,7 +4219,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithPercent.Metadata.builder() + Price.UnitWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3847,11 +4239,11 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithPercent.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitWithPercentConfig( - Price.UnitWithPercent.UnitWithPercentConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .unitWithProrationConfig( + Price.UnitWithProration.UnitWithProrationConfig.builder() + .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( @@ -3870,9 +4262,9 @@ internal class PriceTest { } @Test - fun ofMatrixWithAllocation() { - val matrixWithAllocation = - Price.MatrixWithAllocation.builder() + fun ofGroupedAllocation() { + val groupedAllocation = + Price.GroupedAllocation.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -3881,7 +4273,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) + .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) + .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() @@ -3918,6 +4318,13 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedAllocationConfig( + Price.GroupedAllocation.GroupedAllocationConfig.builder() + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3925,19 +4332,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .matrixWithAllocationConfig( - MatrixWithAllocationConfig.builder() - .allocation(0.0) - .defaultUnitAmount("default_unit_amount") - .addDimension("string") - .addMatrixValue( - MatrixValue.builder() - .addDimensionValue("string") - .unitAmount("unit_amount") - .build() - ) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -3953,7 +4347,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithAllocation.Metadata.builder() + Price.GroupedAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3973,7 +4367,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithAllocation.PriceType.USAGE_PRICE) + .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -3983,45 +4377,45 @@ internal class PriceTest { ) .build() - val price = Price.ofMatrixWithAllocation(matrixWithAllocation) + val price = Price.ofGroupedAllocation(groupedAllocation) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty - assertThat(price.matrixWithAllocation()).contains(matrixWithAllocation) + assertThat(price.matrixWithAllocation()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty - assertThat(price.groupedAllocation()).isEmpty + assertThat(price.groupedAllocation()).contains(groupedAllocation) + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofMatrixWithAllocationRoundtrip() { + fun ofGroupedAllocationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofMatrixWithAllocation( - Price.MatrixWithAllocation.builder() + Price.ofGroupedAllocation( + Price.GroupedAllocation.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4030,7 +4424,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) + .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) + .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() @@ -4067,6 +4469,13 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedAllocationConfig( + Price.GroupedAllocation.GroupedAllocationConfig.builder() + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4074,19 +4483,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .matrixWithAllocationConfig( - MatrixWithAllocationConfig.builder() - .allocation(0.0) - .defaultUnitAmount("default_unit_amount") - .addDimension("string") - .addMatrixValue( - MatrixValue.builder() - .addDimensionValue("string") - .unitAmount("unit_amount") - .build() - ) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -4102,7 +4498,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithAllocation.Metadata.builder() + Price.GroupedAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4122,7 +4518,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithAllocation.PriceType.USAGE_PRICE) + .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4140,9 +4536,9 @@ internal class PriceTest { } @Test - fun ofTieredWithProration() { - val tieredWithProration = - Price.TieredWithProration.builder() + fun ofBulkWithProration() { + val bulkWithProration = + Price.BulkWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4151,7 +4547,31 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredWithProration.Cadence.ONE_TIME) + .billingMode(Price.BulkWithProration.BillingMode.IN_ADVANCE) + .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) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -4210,7 +4630,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithProration.Metadata.builder() + Price.BulkWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4230,13 +4650,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) + .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredWithProrationConfig( - Price.TieredWithProration.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -4245,45 +4660,45 @@ internal class PriceTest { ) .build() - val price = Price.ofTieredWithProration(tieredWithProration) + val price = Price.ofBulkWithProration(bulkWithProration) - assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty + assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty - assertThat(price.tieredWithProration()).contains(tieredWithProration) + assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).contains(bulkWithProration) assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofTieredWithProrationRoundtrip() { + fun ofBulkWithProrationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofTieredWithProration( - Price.TieredWithProration.builder() + Price.ofBulkWithProration( + Price.BulkWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4292,7 +4707,31 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredWithProration.Cadence.ONE_TIME) + .billingMode(Price.BulkWithProration.BillingMode.IN_ADVANCE) + .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) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -4351,7 +4790,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithProration.Metadata.builder() + Price.BulkWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4371,13 +4810,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) + .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredWithProrationConfig( - Price.TieredWithProration.TieredWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -4394,9 +4828,9 @@ internal class PriceTest { } @Test - fun ofUnitWithProration() { - val unitWithProration = - Price.UnitWithProration.builder() + fun ofGroupedWithProratedMinimum() { + val groupedWithProratedMinimum = + Price.GroupedWithProratedMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4405,7 +4839,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitWithProration.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) + .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() @@ -4442,6 +4884,13 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedWithProratedMinimumConfig( + Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4464,7 +4913,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithProration.Metadata.builder() + Price.GroupedWithProratedMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4484,13 +4933,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitWithProrationConfig( - Price.UnitWithProration.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -4499,45 +4943,45 @@ internal class PriceTest { ) .build() - val price = Price.ofUnitWithProration(unitWithProration) + val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty assertThat(price.tieredWithProration()).isEmpty - assertThat(price.unitWithProration()).contains(unitWithProration) + assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty - assertThat(price.groupedWithProratedMinimum()).isEmpty + assertThat(price.bulkWithProration()).isEmpty + assertThat(price.groupedWithProratedMinimum()).contains(groupedWithProratedMinimum) assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofUnitWithProrationRoundtrip() { + fun ofGroupedWithProratedMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofUnitWithProration( - Price.UnitWithProration.builder() + Price.ofGroupedWithProratedMinimum( + Price.GroupedWithProratedMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4546,7 +4990,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitWithProration.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) + .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() @@ -4583,6 +5035,13 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedWithProratedMinimumConfig( + Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() + .groupingKey("x") + .minimum("minimum") + .unitRate("unit_rate") + .build() + ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4605,7 +5064,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithProration.Metadata.builder() + Price.GroupedWithProratedMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4625,13 +5084,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitWithProrationConfig( - Price.UnitWithProration.UnitWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -4648,9 +5102,9 @@ internal class PriceTest { } @Test - fun ofGroupedAllocation() { - val groupedAllocation = - Price.GroupedAllocation.builder() + fun ofGroupedWithMeteredMinimum() { + val groupedWithMeteredMinimum = + Price.GroupedWithMeteredMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4659,7 +5113,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) + .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() @@ -4696,9 +5158,28 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedAllocationConfig( - Price.GroupedAllocation.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .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( @@ -4723,7 +5204,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedAllocation.Metadata.builder() + Price.GroupedWithMeteredMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4743,7 +5224,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4753,45 +5234,45 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedAllocation(groupedAllocation) + val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty - assertThat(price.groupedAllocation()).contains(groupedAllocation) + assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty - assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMeteredMinimum()).contains(groupedWithMeteredMinimum) + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedAllocationRoundtrip() { + fun ofGroupedWithMeteredMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedAllocation( - Price.GroupedAllocation.builder() + Price.ofGroupedWithMeteredMinimum( + Price.GroupedWithMeteredMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4800,7 +5281,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) + .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() @@ -4837,9 +5326,28 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedAllocationConfig( - Price.GroupedAllocation.GroupedAllocationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .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( @@ -4864,7 +5372,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedAllocation.Metadata.builder() + Price.GroupedWithMeteredMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4884,7 +5392,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -4902,9 +5410,9 @@ internal class PriceTest { } @Test - fun ofGroupedWithProratedMinimum() { - val groupedWithProratedMinimum = - Price.GroupedWithProratedMinimum.builder() + fun ofGroupedWithMinMaxThresholds() { + val groupedWithMinMaxThresholds = + Price.GroupedWithMinMaxThresholds.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4913,7 +5421,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) + .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() @@ -4950,9 +5466,12 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithProratedMinimumConfig( - Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupedWithMinMaxThresholdsConfig( + Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig.builder() + .groupingKey("x") + .maximumCharge("maximum_charge") + .minimumCharge("minimum_charge") + .perUnitRate("per_unit_rate") .build() ) .invoicingCycleConfiguration( @@ -4977,7 +5496,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithProratedMinimum.Metadata.builder() + Price.GroupedWithMinMaxThresholds.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4997,7 +5516,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5007,20 +5526,17 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + val price = Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -5028,24 +5544,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty - assertThat(price.groupedWithProratedMinimum()).contains(groupedWithProratedMinimum) + assertThat(price.bulkWithProration()).isEmpty + assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).contains(groupedWithMinMaxThresholds) assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedWithProratedMinimumRoundtrip() { + fun ofGroupedWithMinMaxThresholdsRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedWithProratedMinimum( - Price.GroupedWithProratedMinimum.builder() + Price.ofGroupedWithMinMaxThresholds( + Price.GroupedWithMinMaxThresholds.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5054,7 +5573,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) + .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() @@ -5091,9 +5618,13 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithProratedMinimumConfig( - Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .groupedWithMinMaxThresholdsConfig( + Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig + .builder() + .groupingKey("x") + .maximumCharge("maximum_charge") + .minimumCharge("minimum_charge") + .perUnitRate("per_unit_rate") .build() ) .invoicingCycleConfiguration( @@ -5118,7 +5649,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithProratedMinimum.Metadata.builder() + Price.GroupedWithMinMaxThresholds.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5138,7 +5669,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5156,9 +5687,9 @@ internal class PriceTest { } @Test - fun ofGroupedWithMeteredMinimum() { - val groupedWithMeteredMinimum = - Price.GroupedWithMeteredMinimum.builder() + fun ofMatrixWithDisplayName() { + val matrixWithDisplayName = + Price.MatrixWithDisplayName.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5167,7 +5698,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) + .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) + .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() @@ -5204,11 +5743,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMeteredMinimumConfig( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5216,6 +5750,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") @@ -5231,7 +5778,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMeteredMinimum.Metadata.builder() + Price.MatrixWithDisplayName.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5251,7 +5798,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5261,20 +5808,17 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -5282,24 +5826,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty - assertThat(price.groupedWithProratedMinimum()).isEmpty - assertThat(price.groupedWithMeteredMinimum()).contains(groupedWithMeteredMinimum) - assertThat(price.matrixWithDisplayName()).isEmpty assertThat(price.bulkWithProration()).isEmpty + assertThat(price.groupedWithProratedMinimum()).isEmpty + assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.matrixWithDisplayName()).contains(matrixWithDisplayName) assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedWithMeteredMinimumRoundtrip() { + fun ofMatrixWithDisplayNameRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedWithMeteredMinimum( - Price.GroupedWithMeteredMinimum.builder() + Price.ofMatrixWithDisplayName( + Price.MatrixWithDisplayName.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5308,7 +5855,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) + .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) + .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() @@ -5345,11 +5900,6 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMeteredMinimumConfig( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5357,6 +5907,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") @@ -5372,7 +5935,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMeteredMinimum.Metadata.builder() + Price.MatrixWithDisplayName.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5392,7 +5955,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5410,9 +5973,9 @@ internal class PriceTest { } @Test - fun ofMatrixWithDisplayName() { - val matrixWithDisplayName = - Price.MatrixWithDisplayName.builder() + fun ofGroupedTieredPackage() { + val groupedTieredPackage = + Price.GroupedTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5421,7 +5984,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) + .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) + .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() @@ -5458,6 +6029,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) @@ -5465,11 +6054,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") @@ -5485,7 +6069,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithDisplayName.Metadata.builder() + Price.GroupedTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5505,7 +6089,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5515,20 +6099,17 @@ internal class PriceTest { ) .build() - val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) + val price = Price.ofGroupedTieredPackage(groupedTieredPackage) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -5536,24 +6117,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty - assertThat(price.matrixWithDisplayName()).contains(matrixWithDisplayName) - assertThat(price.bulkWithProration()).isEmpty - assertThat(price.groupedTieredPackage()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.matrixWithDisplayName()).isEmpty + assertThat(price.groupedTieredPackage()).contains(groupedTieredPackage) assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofMatrixWithDisplayNameRoundtrip() { + fun ofGroupedTieredPackageRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofMatrixWithDisplayName( - Price.MatrixWithDisplayName.builder() + Price.ofGroupedTieredPackage( + Price.GroupedTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5562,7 +6146,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) + .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) + .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() @@ -5599,6 +6191,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) @@ -5606,11 +6216,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") @@ -5626,7 +6231,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithDisplayName.Metadata.builder() + Price.GroupedTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5646,7 +6251,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5664,9 +6269,9 @@ internal class PriceTest { } @Test - fun ofBulkWithProration() { - val bulkWithProration = - Price.BulkWithProration.builder() + fun ofMaxGroupTieredPackage() { + val maxGroupTieredPackage = + Price.MaxGroupTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5675,12 +6280,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkWithProrationConfig( - Price.BulkWithProration.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) + .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") .build() ) - .cadence(Price.BulkWithProration.Cadence.ONE_TIME) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5724,6 +6332,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") @@ -5739,7 +6365,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkWithProration.Metadata.builder() + Price.MaxGroupTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5759,7 +6385,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) + .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5769,20 +6395,17 @@ internal class PriceTest { ) .build() - val price = Price.ofBulkWithProration(bulkWithProration) + val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -5790,24 +6413,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).contains(bulkWithProration) assertThat(price.groupedTieredPackage()).isEmpty - assertThat(price.maxGroupTieredPackage()).isEmpty + assertThat(price.maxGroupTieredPackage()).contains(maxGroupTieredPackage) assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofBulkWithProrationRoundtrip() { + fun ofMaxGroupTieredPackageRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofBulkWithProration( - Price.BulkWithProration.builder() + Price.ofMaxGroupTieredPackage( + Price.MaxGroupTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5816,12 +6442,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .bulkWithProrationConfig( - Price.BulkWithProration.BulkWithProrationConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) + .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .addCompositePriceFilter( + TransformPriceFilter.builder() + .field(TransformPriceFilter.Field.PRICE_ID) + .operator(TransformPriceFilter.Operator.INCLUDES) + .addValue("string") .build() ) - .cadence(Price.BulkWithProration.Cadence.ONE_TIME) .conversionRate(0.0) .unitConversionRateConfig( ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() @@ -5865,6 +6494,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") @@ -5880,7 +6529,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkWithProration.Metadata.builder() + Price.MaxGroupTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5900,7 +6549,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) + .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5918,9 +6567,9 @@ internal class PriceTest { } @Test - fun ofGroupedTieredPackage() { - val groupedTieredPackage = - Price.GroupedTieredPackage.builder() + fun ofScalableMatrixWithUnitPricing() { + val scalableMatrixWithUnitPricing = + Price.ScalableMatrixWithUnitPricing.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5929,7 +6578,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) + .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) + .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() @@ -5966,11 +6623,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) @@ -5993,7 +6645,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPackage.Metadata.builder() + Price.ScalableMatrixWithUnitPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6013,8 +6665,26 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .scalableMatrixWithUnitPricingConfig( + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig + .builder() + .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( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6023,20 +6693,17 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedTieredPackage(groupedTieredPackage) + val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -6044,24 +6711,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty - assertThat(price.groupedTieredPackage()).contains(groupedTieredPackage) + assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty - assertThat(price.scalableMatrixWithUnitPricing()).isEmpty + assertThat(price.scalableMatrixWithUnitPricing()).contains(scalableMatrixWithUnitPricing) assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedTieredPackageRoundtrip() { + fun ofScalableMatrixWithUnitPricingRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedTieredPackage( - Price.GroupedTieredPackage.builder() + Price.ofScalableMatrixWithUnitPricing( + Price.ScalableMatrixWithUnitPricing.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6070,7 +6740,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) + .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) + .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() @@ -6107,11 +6785,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) @@ -6134,7 +6807,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPackage.Metadata.builder() + Price.ScalableMatrixWithUnitPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6154,8 +6827,27 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .scalableMatrixWithUnitPricingConfig( + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig + .builder() + .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( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6172,9 +6864,9 @@ internal class PriceTest { } @Test - fun ofMaxGroupTieredPackage() { - val maxGroupTieredPackage = - Price.MaxGroupTieredPackage.builder() + fun ofScalableMatrixWithTieredPricing() { + val scalableMatrixWithTieredPricing = + Price.ScalableMatrixWithTieredPricing.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6183,7 +6875,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) + .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() @@ -6227,11 +6927,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") @@ -6247,7 +6942,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MaxGroupTieredPackage.Metadata.builder() + Price.ScalableMatrixWithTieredPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6261,14 +6956,49 @@ internal class PriceTest { .addValue("string") .build() ) - .minimumAmount("minimum_amount") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .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() ) - .minimumAmount("minimum_amount") - .name("name") - .planPhaseOrder(0L) - .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) - .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6277,20 +7007,17 @@ internal class PriceTest { ) .build() - val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) + val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -6298,24 +7025,28 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty - assertThat(price.maxGroupTieredPackage()).contains(maxGroupTieredPackage) + assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty - assertThat(price.scalableMatrixWithTieredPricing()).isEmpty + assertThat(price.scalableMatrixWithTieredPricing()) + .contains(scalableMatrixWithTieredPricing) assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofMaxGroupTieredPackageRoundtrip() { + fun ofScalableMatrixWithTieredPricingRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofMaxGroupTieredPackage( - Price.MaxGroupTieredPackage.builder() + Price.ofScalableMatrixWithTieredPricing( + Price.ScalableMatrixWithTieredPricing.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6324,7 +7055,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) + .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() @@ -6368,11 +7107,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") @@ -6388,7 +7122,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MaxGroupTieredPackage.Metadata.builder() + Price.ScalableMatrixWithTieredPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6408,8 +7142,43 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MaxGroupTieredPackage.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") @@ -6426,9 +7195,9 @@ internal class PriceTest { } @Test - fun ofScalableMatrixWithUnitPricing() { - val scalableMatrixWithUnitPricing = - Price.ScalableMatrixWithUnitPricing.builder() + fun ofCumulativeGroupedBulk() { + val cumulativeGroupedBulk = + Price.CumulativeGroupedBulk.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6437,7 +7206,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) + .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) + .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() @@ -6455,6 +7232,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() @@ -6496,7 +7286,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithUnitPricing.Metadata.builder() + Price.CumulativeGroupedBulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6516,14 +7306,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) + .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithUnitPricingConfig( - Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6532,20 +7316,17 @@ internal class PriceTest { ) .build() - val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -6553,24 +7334,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty - assertThat(price.scalableMatrixWithUnitPricing()).contains(scalableMatrixWithUnitPricing) + assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty - assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.cumulativeGroupedBulk()).contains(cumulativeGroupedBulk) + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofScalableMatrixWithUnitPricingRoundtrip() { + fun ofCumulativeGroupedBulkRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofScalableMatrixWithUnitPricing( - Price.ScalableMatrixWithUnitPricing.builder() + Price.ofCumulativeGroupedBulk( + Price.CumulativeGroupedBulk.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6579,7 +7363,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) + .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) + .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() @@ -6597,6 +7389,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() @@ -6638,7 +7444,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithUnitPricing.Metadata.builder() + Price.CumulativeGroupedBulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6658,14 +7464,8 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) + .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithUnitPricingConfig( - Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6682,9 +7482,9 @@ internal class PriceTest { } @Test - fun ofScalableMatrixWithTieredPricing() { - val scalableMatrixWithTieredPricing = - Price.ScalableMatrixWithTieredPricing.builder() + fun ofMinimum() { + val minimum = + Price.Minimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6693,7 +7493,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .billingMode(Price.Minimum.BillingMode.IN_ADVANCE) + .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() @@ -6752,7 +7560,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithTieredPricing.Metadata.builder() + Price.Minimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6770,16 +7578,16 @@ internal class PriceTest { .build() ) .minimumAmount("minimum_amount") + .minimumConfig( + Price.Minimum.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) + .priceType(Price.Minimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithTieredPricingConfig( - Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6788,20 +7596,17 @@ internal class PriceTest { ) .build() - val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) + val price = Price.ofMinimum(minimum) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -6809,25 +7614,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty - assertThat(price.scalableMatrixWithTieredPricing()) - .contains(scalableMatrixWithTieredPricing) + assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.minimum()).contains(minimum) + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty } @Test - fun ofScalableMatrixWithTieredPricingRoundtrip() { + fun ofMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofScalableMatrixWithTieredPricing( - Price.ScalableMatrixWithTieredPricing.builder() + Price.ofMinimum( + Price.Minimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6836,7 +7643,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .billingMode(Price.Minimum.BillingMode.IN_ADVANCE) + .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() @@ -6895,7 +7710,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithTieredPricing.Metadata.builder() + Price.Minimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6913,16 +7728,16 @@ internal class PriceTest { .build() ) .minimumAmount("minimum_amount") + .minimumConfig( + Price.Minimum.MinimumConfig.builder() + .minimumAmount("minimum_amount") + .prorated(true) + .build() + ) .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) + .priceType(Price.Minimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithTieredPricingConfig( - Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") @@ -6939,9 +7754,9 @@ internal class PriceTest { } @Test - fun ofCumulativeGroupedBulk() { - val cumulativeGroupedBulk = - Price.CumulativeGroupedBulk.builder() + fun ofPercent() { + val percent = + Price.Percent.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6950,7 +7765,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .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() @@ -6968,11 +7791,6 @@ internal class PriceTest { ) .build() ) - .cumulativeGroupedBulkConfig( - Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .currency("currency") .discount( PercentageDiscount.builder() @@ -7014,7 +7832,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedBulk.Metadata.builder() + Price.Percent.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7033,8 +7851,9 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") + .percentConfig(Price.Percent.PercentConfig.builder().percent(0.0).build()) .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) + .priceType(Price.Percent.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -7044,20 +7863,17 @@ internal class PriceTest { ) .build() - val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + val price = Price.ofPercent(percent) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -7065,24 +7881,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty - assertThat(price.cumulativeGroupedBulk()).contains(cumulativeGroupedBulk) - assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.cumulativeGroupedBulk()).isEmpty + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).contains(percent) + assertThat(price.eventOutput()).isEmpty } @Test - fun ofCumulativeGroupedBulkRoundtrip() { + fun ofPercentRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofCumulativeGroupedBulk( - Price.CumulativeGroupedBulk.builder() + Price.ofPercent( + Price.Percent.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -7091,7 +7910,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .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() @@ -7109,11 +7936,6 @@ internal class PriceTest { ) .build() ) - .cumulativeGroupedBulkConfig( - Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) .currency("currency") .discount( PercentageDiscount.builder() @@ -7155,7 +7977,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedBulk.Metadata.builder() + Price.Percent.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7174,8 +7996,9 @@ internal class PriceTest { ) .minimumAmount("minimum_amount") .name("name") + .percentConfig(Price.Percent.PercentConfig.builder().percent(0.0).build()) .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) + .priceType(Price.Percent.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -7193,9 +8016,9 @@ internal class PriceTest { } @Test - fun ofGroupedWithMinMaxThresholds() { - val groupedWithMinMaxThresholds = - Price.GroupedWithMinMaxThresholds.builder() + fun ofEventOutput() { + val eventOutput = + Price.EventOutput.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -7204,7 +8027,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) + .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() @@ -7239,13 +8070,14 @@ internal class PriceTest { .reason("reason") .build() ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .groupedWithMinMaxThresholdsConfig( - Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .eventOutputConfig( + Price.EventOutput.EventOutputConfig.builder() + .unitRatingKey("x") + .groupingKey("grouping_key") .build() ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7268,7 +8100,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMinMaxThresholds.Metadata.builder() + Price.EventOutput.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7288,7 +8120,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) + .priceType(Price.EventOutput.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -7298,20 +8130,17 @@ internal class PriceTest { ) .build() - val price = Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + val price = Price.ofEventOutput(eventOutput) assertThat(price.unit()).isEmpty - assertThat(price.package_()).isEmpty - assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty - assertThat(price.tieredBps()).isEmpty - assertThat(price.bps()).isEmpty - assertThat(price.bulkBps()).isEmpty assertThat(price.bulk()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty assertThat(price.thresholdTotalAmount()).isEmpty assertThat(price.tieredPackage()).isEmpty - assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty assertThat(price.tieredPackageWithMinimum()).isEmpty assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty @@ -7319,24 +8148,27 @@ internal class PriceTest { assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).contains(groupedWithMinMaxThresholds) + assertThat(price.minimum()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).contains(eventOutput) } @Test - fun ofGroupedWithMinMaxThresholdsRoundtrip() { + fun ofEventOutputRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedWithMinMaxThresholds( - Price.GroupedWithMinMaxThresholds.builder() + Price.ofEventOutput( + Price.EventOutput.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -7345,7 +8177,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) + .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() @@ -7380,14 +8220,14 @@ internal class PriceTest { .reason("reason") .build() ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .groupedWithMinMaxThresholdsConfig( - Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .eventOutputConfig( + Price.EventOutput.EventOutputConfig.builder() + .unitRatingKey("x") + .groupingKey("grouping_key") .build() ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7410,7 +8250,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMinMaxThresholds.Metadata.builder() + Price.EventOutput.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7430,7 +8270,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) + .priceType(Price.EventOutput.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt index 0b572915..18a86889 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyParamsTest.kt +++ b/orb-java-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()).contains("description") + assertThat(body.markAsPaid()).contains(true) assertThat(body.previouslyCollectedAmount()).contains("previously_collected_amount") } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index b360b6c1..88d81031 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-java-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() @@ -388,7 +389,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -551,7 +560,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -778,11 +795,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") @@ -807,7 +826,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") @@ -829,10 +849,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") @@ -853,7 +877,9 @@ internal class SubscriptionChangeApplyResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -898,13 +924,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( @@ -1032,7 +1064,23 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -1204,6 +1252,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1235,7 +1284,8 @@ internal class SubscriptionChangeApplyResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1260,16 +1310,24 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1292,7 +1350,10 @@ internal class SubscriptionChangeApplyResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -1657,7 +1718,23 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -1829,6 +1906,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1895,6 +1973,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 +2074,7 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -2306,7 +2388,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2458,7 +2548,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2676,11 +2774,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") @@ -2703,7 +2802,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") @@ -2723,10 +2823,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") @@ -2740,7 +2844,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( @@ -2781,11 +2890,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( @@ -2904,7 +3018,20 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -3067,6 +3194,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3098,7 +3226,8 @@ internal class SubscriptionChangeApplyResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3120,16 +3249,23 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3152,7 +3288,9 @@ internal class SubscriptionChangeApplyResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -3487,7 +3625,20 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -3650,6 +3801,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3713,6 +3865,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 +3976,7 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -4136,7 +4292,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -4299,7 +4463,15 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -4526,11 +4698,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") @@ -4555,7 +4729,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") @@ -4577,10 +4752,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") @@ -4601,7 +4780,9 @@ internal class SubscriptionChangeApplyResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -4646,13 +4827,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( @@ -4780,7 +4967,23 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -4952,6 +5155,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -4983,7 +5187,8 @@ internal class SubscriptionChangeApplyResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5008,16 +5213,24 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -5040,7 +5253,10 @@ internal class SubscriptionChangeApplyResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -5405,7 +5621,23 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -5577,6 +5809,7 @@ internal class SubscriptionChangeApplyResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5643,6 +5876,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-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 80b3221b..84ea51bf 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-java-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() @@ -388,7 +389,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -551,7 +560,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -778,11 +795,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") @@ -807,7 +826,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") @@ -829,10 +849,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") @@ -853,7 +877,9 @@ internal class SubscriptionChangeCancelResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -898,13 +924,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( @@ -1032,7 +1064,23 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -1204,6 +1252,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1235,7 +1284,8 @@ internal class SubscriptionChangeCancelResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1260,16 +1310,24 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1292,7 +1350,10 @@ internal class SubscriptionChangeCancelResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -1657,7 +1718,23 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -1829,6 +1906,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1895,6 +1973,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 +2074,7 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -2306,7 +2388,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2458,7 +2548,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2676,11 +2774,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") @@ -2703,7 +2802,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") @@ -2723,10 +2823,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") @@ -2740,7 +2844,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( @@ -2781,11 +2890,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( @@ -2904,7 +3018,20 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -3067,6 +3194,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3098,7 +3226,8 @@ internal class SubscriptionChangeCancelResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3120,16 +3249,23 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3152,7 +3288,9 @@ internal class SubscriptionChangeCancelResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -3487,7 +3625,20 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -3650,6 +3801,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3713,6 +3865,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 +3976,7 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -4136,7 +4292,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -4299,7 +4463,15 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -4526,11 +4698,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") @@ -4555,7 +4729,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") @@ -4577,10 +4752,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") @@ -4601,7 +4780,9 @@ internal class SubscriptionChangeCancelResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -4646,13 +4827,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( @@ -4780,7 +4967,23 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -4952,6 +5155,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -4983,7 +5187,8 @@ internal class SubscriptionChangeCancelResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5008,16 +5213,24 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -5040,7 +5253,10 @@ internal class SubscriptionChangeCancelResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -5405,7 +5621,23 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -5577,6 +5809,7 @@ internal class SubscriptionChangeCancelResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5643,6 +5876,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-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index f4f60324..645d5ca0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-java-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() @@ -388,7 +389,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -551,7 +560,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -778,11 +795,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") @@ -807,7 +826,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") @@ -829,10 +849,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") @@ -853,7 +877,9 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -898,13 +924,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( @@ -1032,7 +1064,23 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -1204,6 +1252,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1235,7 +1284,8 @@ internal class SubscriptionChangeRetrieveResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1260,16 +1310,24 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -1292,7 +1350,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -1657,7 +1718,23 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -1829,6 +1906,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -1895,6 +1973,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 +2074,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -2306,7 +2388,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2458,7 +2548,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -2676,11 +2774,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") @@ -2703,7 +2802,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") @@ -2723,10 +2823,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") @@ -2740,7 +2844,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( @@ -2781,11 +2890,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( @@ -2904,7 +3018,20 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -3067,6 +3194,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3098,7 +3226,8 @@ internal class SubscriptionChangeRetrieveResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -3120,16 +3249,23 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -3152,7 +3288,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status.ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -3487,7 +3625,20 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -3650,6 +3801,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -3713,6 +3865,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 +3976,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -4136,7 +4292,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -4299,7 +4463,15 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -4526,11 +4698,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") @@ -4555,7 +4729,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") @@ -4577,10 +4752,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") @@ -4601,7 +4780,9 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .startingBalance("33.00") .type( - Invoice.CustomerBalanceTransaction.Type + ChangedSubscriptionResources.CreatedInvoice + .CustomerBalanceTransaction + .Type .INCREMENT ) .build() @@ -4646,13 +4827,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( @@ -4780,7 +4967,23 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -4952,6 +5155,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -4983,7 +5187,8 @@ internal class SubscriptionChangeRetrieveResponseTest { .maximumAmount("maximum_amount") .memo("memo") .metadata( - Invoice.Metadata.builder() + ChangedSubscriptionResources.CreatedInvoice.Metadata + .builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -5008,16 +5213,24 @@ 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( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) .succeeded(true) .build() ) @@ -5040,7 +5253,10 @@ internal class SubscriptionChangeRetrieveResponseTest { .state("state") .build() ) - .status(Invoice.Status.ISSUED) + .status( + ChangedSubscriptionResources.CreatedInvoice.Status + .ISSUED + ) .subscription( SubscriptionMinified.builder() .id("VDGsT23osdLb84KD") @@ -5405,7 +5621,23 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .billingMode( + Price.Unit.BillingMode.IN_ADVANCE + ) .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() @@ -5577,6 +5809,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Tier One") .quantity(5.0) .type(MatrixSubLineItem.Type.MATRIX) + .scaledQuantity(0.0) .build() ) .subtotal("9.00") @@ -5643,6 +5876,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-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index 09f8ae0d..26f07d4c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -33,7 +33,15 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -175,7 +183,15 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -316,7 +332,15 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionListParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionListParamsTest.kt index 1c1c73dd..2fdd22e5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionListParamsTest.kt +++ b/orb-java-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() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 5dec5393..2561e56b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -94,6 +94,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -117,7 +118,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() ) @@ -246,6 +247,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -269,7 +271,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() ) @@ -384,6 +386,7 @@ internal class SubscriptionPriceIntervalsParamsTest { assertThat(body.addAdjustments().getOrNull()) .containsExactly( SubscriptionPriceIntervalsParams.AddAdjustment.builder() + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -407,7 +410,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-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index c7eae5d7..44c43086 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -59,6 +59,7 @@ internal class SubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -358,7 +359,15 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -496,7 +505,15 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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 +673,7 @@ internal class SubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -964,7 +982,15 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1097,7 +1123,15 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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 +1293,7 @@ internal class SubscriptionTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -1558,7 +1593,15 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1696,7 +1739,15 @@ internal class SubscriptionTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 6e12850f..5616656c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -70,6 +70,7 @@ internal class SubscriptionsTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -385,7 +386,15 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -548,7 +557,15 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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 +749,7 @@ internal class SubscriptionsTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -1045,7 +1063,15 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1197,7 +1223,15 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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 +1419,7 @@ internal class SubscriptionsTest { .id("id") .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .balance("balance") .billingAddress( Address.builder() @@ -1700,7 +1735,15 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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() @@ -1863,7 +1906,15 @@ internal class SubscriptionsTest { ) .build() ) + .billingMode(Price.Unit.BillingMode.IN_ADVANCE) .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-java-core/src/test/kotlin/com/withorb/api/models/TierConfigTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TierConfigTest.kt deleted file mode 100644 index 42c54140..00000000 --- a/orb-java-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()).contains(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-java-core/src/test/kotlin/com/withorb/api/models/TierSubLineItemTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TierSubLineItemTest.kt index cd2f186f..48415fea 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/TierSubLineItemTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/models/TieredBpsConfigTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TieredBpsConfigTest.kt deleted file mode 100644 index 8b7c363b..00000000 --- a/orb-java-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-java-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt index 591b40a6..eb972aae 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt index 834d04a5..a331a786 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt index f185150d..15427a55 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt +++ b/orb-java-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") @@ -135,6 +136,7 @@ internal class CustomerServiceAsyncTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") @@ -313,6 +315,7 @@ internal class CustomerServiceAsyncTest { ) .addAdditionalEmail("string") .autoCollection(true) + .autoIssuance(true) .billingAddress( AddressInput.builder() .city("city") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index 3cae20e2..a1eb8906 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-java-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( @@ -92,11 +93,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-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt index 3c74803f..865b22a8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncTest.kt @@ -41,6 +41,7 @@ internal class SubscriptionChangeServiceAsyncTest { SubscriptionChangeApplyParams.builder() .subscriptionChangeId("subscription_change_id") .description("description") + .markAsPaid(true) .previouslyCollectedAmount("previously_collected_amount") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 232fe057..04e4057a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -587,6 +587,7 @@ internal class SubscriptionServiceAsyncTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -610,7 +611,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-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt index bd7fbe14..794b0a6c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt @@ -55,6 +55,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) @@ -102,6 +103,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-java-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt index 3218fe7e..8838c4b6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 954109a5..f972fd65 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt index 4fe649e8..e4ab8a93 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceTest.kt +++ b/orb-java-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() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 3c88f501..2d6d063a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-java-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-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt index c484ee91..f57c343c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt +++ b/orb-java-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) diff --git a/orb-java-example/build.gradle.kts b/orb-java-example/build.gradle.kts index 4957bd3c..3e7cb223 100644 --- a/orb-java-example/build.gradle.kts +++ b/orb-java-example/build.gradle.kts @@ -18,7 +18,7 @@ tasks.withType().configureEach { application { // Use `./gradlew :orb-java-example:run` to run `Main` - // Use `./gradlew :orb-java-example:run -Dexample=Something` to run `SomethingExample` + // Use `./gradlew :orb-java-example:run -Pexample=Something` to run `SomethingExample` mainClass = "com.withorb.api.example.${ if (project.hasProperty("example")) "${project.property("example")}Example" diff --git a/orb-java-proguard-test/build.gradle.kts b/orb-java-proguard-test/build.gradle.kts new file mode 100644 index 00000000..f6eac3d8 --- /dev/null +++ b/orb-java-proguard-test/build.gradle.kts @@ -0,0 +1,101 @@ +plugins { + id("orb.kotlin") + id("com.gradleup.shadow") version "8.3.8" +} + +buildscript { + repositories { + google() + } + + dependencies { + classpath("com.guardsquare:proguard-gradle:7.4.2") + classpath("com.android.tools:r8:8.3.37") + } +} + +dependencies { + testImplementation(project(":orb-java")) + 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") +} + +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") + + 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-java-core/src/main/resources/META-INF/proguard/orb-java-core.pro") +} + +val testProGuard by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(proguardJar) + notCompatibleWithConfigurationCache("ProGuard") + + 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( + "--release", + "--classfile", + "--output", r8JarPath, + "--lib", System.getProperty("java.home"), + "--pg-conf", "./test.pro", + "--pg-conf", "../orb-java-core/src/main/resources/META-INF/proguard/orb-java-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-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt b/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt new file mode 100644 index 00000000..388dd46e --- /dev/null +++ b/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt @@ -0,0 +1,125 @@ +// 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.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 +import org.junit.jupiter.api.Test + +internal class ProGuardCompatibilityTest { + + companion object { + + @JvmStatic + 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) } + } + } + + @Test + fun proguardRules() { + val rulesFile = + javaClass.classLoader.getResourceAsStream("META-INF/proguard/orb-java-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 conversionRateConfigRoundtrip() { + 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 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-java-proguard-test/test.pro b/orb-java-proguard-test/test.pro new file mode 100644 index 00000000..bda3f400 --- /dev/null +++ b/orb-java-proguard-test/test.pro @@ -0,0 +1,9 @@ +# 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.** { *; } + +# 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 00000000..f4063482 --- /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/fast-format b/scripts/fast-format new file mode 100755 index 00000000..1b3bc473 --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -euo pipefail + +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + +cd "$(dirname "$0")/.." +echo "Changed to directory: $(pwd)" + +if [ $# -eq 0 ]; then + echo "Usage: $0 [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +FILE_LIST="$1" + +echo "Looking for file: $FILE_LIST" + +if [ ! -f "$FILE_LIST" ]; then + echo "Error: File '$FILE_LIST' not found" + exit 1 +fi + +if ! command -v ktfmt-fast-format &> /dev/null; then + echo "Error: ktfmt-fast-format not found" + exit 1 +fi + +# Process Kotlin files +echo "==> Looking for Kotlin files" +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/' || true) +echo "==> Done looking for Kotlin files" + +if [[ -n "$kt_files" ]]; then + echo "==> will format Kotlin files" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" +else + echo "No Kotlin files to format -- expected outcome during incremental formatting" +fi + +# TODO(mbudayr): support palantir-java-format +# Process Java files +# grep -E '\.java$' "$FILE_LIST" | grep -v './buildSrc/build/' | tr '\n' '\0' | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/format b/scripts/format index 456a69db..65db1769 100755 --- a/scripts/format +++ b/scripts/format @@ -4,5 +4,18 @@ set -e cd "$(dirname "$0")/.." -echo "==> Running spotlessApply" -./gradlew spotlessApply +if command -v ktfmt &> /dev/null; then + echo "==> Running ktfmt" + ./scripts/kotlin-format +else + echo "==> Running gradlew formatKotlin" + ./gradlew formatKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Running palantir-java-format" + ./scripts/java-format +else + echo "==> Running gradlew formatJava" + ./gradlew formatJava +fi diff --git a/scripts/java-format b/scripts/java-format new file mode 100755 index 00000000..ad5febce --- /dev/null +++ b/scripts/java-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.java" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/kotlin-format b/scripts/kotlin-format new file mode 100755 index 00000000..3b8be9ea --- /dev/null +++ b/scripts/kotlin-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@" diff --git a/scripts/lint b/scripts/lint index e3a5f5e2..dbc8f776 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,5 +4,20 @@ set -e cd "$(dirname "$0")/.." -echo "==> Build classes" -./gradlew build testClasses -x test +echo "==> Running lints" + +if command -v ktfmt &> /dev/null; then + echo "==> Checking ktfmt" + ./scripts/kotlin-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintKotlin" + ./gradlew lintKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Checking palantir-java-format" + ./scripts/java-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintJava" + ./gradlew lintJava +fi diff --git a/scripts/mock b/scripts/mock index d2814ae6..0b28f6ea 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 6b750a74..047bc1db 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 50fd0762..af2b26f3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,14 @@ rootProject.name = "orb-java-root" -include("orb-java") -include("orb-java-client-okhttp") -include("orb-java-core") -include("orb-java-example") +val projectNames = rootDir.listFiles() + ?.asSequence() + .orEmpty() + .filter { file -> + file.isDirectory && + file.name.startsWith("orb-java") && + file.listFiles()?.asSequence().orEmpty().any { it.name == "build.gradle.kts" } + } + .map { it.name } + .toList() +println("projects: $projectNames") +projectNames.forEach { include(it) }